D
DhaneshNair
Hi all,
I hav a file which is actually linkage file (used as an reference
interface between c and c++ files). And this file has got two
structures in it .. When i include this file directly i dont have any
issues. but according to some norms in the review I am not supposed to
use this file direclty in the header file .. but its fine if i use that
inside the corresponding file.
To avoid compiler error, i forward declared the structure as in ex.
struct MyStruct;
class MyClass
{
private :
MyStruct * me;
}
But when the actual cpp file which includes the prev file i mentioned
in the beginning I get a compiler error in actual file which has the
structure defintion.
say like : structure redefined, see myclass.cpp (some thing like this)
So i tried replacing this structure in the linkage .h file to a class
and forward declared it on the MyClass.cpp file.
ex:
//typedef struct
//{
// char *myName;
}MyStruct;
to
class MyStruct
{
public:
char *myName;
}
Now the build is perfect once i forward declare the class..
Do find any reason for it .. Do you find any error in my forward
declaration of struct..
Can u please help me .. what could be the solution.?
I hav a file which is actually linkage file (used as an reference
interface between c and c++ files). And this file has got two
structures in it .. When i include this file directly i dont have any
issues. but according to some norms in the review I am not supposed to
use this file direclty in the header file .. but its fine if i use that
inside the corresponding file.
To avoid compiler error, i forward declared the structure as in ex.
struct MyStruct;
class MyClass
{
private :
MyStruct * me;
}
But when the actual cpp file which includes the prev file i mentioned
in the beginning I get a compiler error in actual file which has the
structure defintion.
say like : structure redefined, see myclass.cpp (some thing like this)
So i tried replacing this structure in the linkage .h file to a class
and forward declared it on the MyClass.cpp file.
ex:
//typedef struct
//{
// char *myName;
}MyStruct;
to
class MyStruct
{
public:
char *myName;
}
Now the build is perfect once i forward declare the class..
Do find any reason for it .. Do you find any error in my forward
declaration of struct..
Can u please help me .. what could be the solution.?