M
michael.d.pedersen
Hello group,
I am new to Visual C++ 8 and have a seemingly trivial problem using
namespaces. The scenario: I have two classes, TestClass1 and
TestClass2, in the namespace Test. I would like to create a reference
to TestClass2 in TestClass1; but the compiler doesn't seem to recognize
the namespace Test and any classes in it.
Here are my class definitions and declarations:
---------- TestClass1.h -------------
#pragma once
#include "TestClass2.h"
namespace Test
{
public ref class TestClass1
{
public:
TestClass1(void);
Test::TestClass2^ t2; // <-- results in error
};
};
----------------- TestClass2.h --------------
#pragma once
#include "TestClass1.h"
namespace Test
{
public ref class TestClass2
{
public:
TestClass2(void);
};
};
-------------- TestClass1.cpp ------------------
#include "StdAfx.h"
#include "TestClass1.h"
Test::TestClass1::TestClass1(void)
{
}
-------------- TestClass2.cpp ------------------
#include "StdAfx.h"
#include "TestClass2.h"
Test::TestClass2::TestClass2(void)
{
}
--------------- end of code ----------------------
Compilation results in the following: "error C2039: 'TestClass2' : is
not a member of 'Test'".
If I include "using namespace Test" in either of the header files, I
get an error saying that the namespace Test does not exist. However,
Intellisense does list TestClass2 as a member of Test, and the
namespace Test is listed in the object browser.
I must be overlooking something embarasingly simple here. Any
suggestions would be much appreciated.
Thanks,
Michael.
I am new to Visual C++ 8 and have a seemingly trivial problem using
namespaces. The scenario: I have two classes, TestClass1 and
TestClass2, in the namespace Test. I would like to create a reference
to TestClass2 in TestClass1; but the compiler doesn't seem to recognize
the namespace Test and any classes in it.
Here are my class definitions and declarations:
---------- TestClass1.h -------------
#pragma once
#include "TestClass2.h"
namespace Test
{
public ref class TestClass1
{
public:
TestClass1(void);
Test::TestClass2^ t2; // <-- results in error
};
};
----------------- TestClass2.h --------------
#pragma once
#include "TestClass1.h"
namespace Test
{
public ref class TestClass2
{
public:
TestClass2(void);
};
};
-------------- TestClass1.cpp ------------------
#include "StdAfx.h"
#include "TestClass1.h"
Test::TestClass1::TestClass1(void)
{
}
-------------- TestClass2.cpp ------------------
#include "StdAfx.h"
#include "TestClass2.h"
Test::TestClass2::TestClass2(void)
{
}
--------------- end of code ----------------------
Compilation results in the following: "error C2039: 'TestClass2' : is
not a member of 'Test'".
If I include "using namespace Test" in either of the header files, I
get an error saying that the namespace Test does not exist. However,
Intellisense does list TestClass2 as a member of Test, and the
namespace Test is listed in the object browser.
I must be overlooking something embarasingly simple here. Any
suggestions would be much appreciated.
Thanks,
Michael.