|
-
January 24th, 2010, 12:43 PM
#1
class visibility
I am new to c++/cli. I looked for several forums but couldnt find a relative answer for my problem. Here, below, two classes in the same namespace. Compiler gives the following error message:
error C2065: 'classA' : undeclared identifier.
When I put the classA before classB it works fine. What is the logic behind this? Is there any way writing classes free from writing sequence?
public ref class classB
{
String^ _b;
public:
void somefunc(){
classA^ clsa = gcnew classA("some string",12);
}
};
public ref class classA
{
private:
Int32 portu;
String^ hostu;
public:
classA(String^ phostu, Int32 pportu)
{
hostu = phostu;
portu = pportu;
}
};
-
January 25th, 2010, 05:29 AM
#2
Re: class visibility
classA^ clsa = gcnew classA("some string",12);
To compile this line, compiler must have definition of classA. If classA is defined later, this line is not compiled.
To reduce compilation dependencies, it is better to move implementation to .cpp file.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|