Two words: Forward Declaration.
I appreciate that, but it doesn't help in this instance because each class contains an object of a class defined in the other file rather than just a pointer to such an object, so the compiler needs to know what the contained object looks like in order to construct the containing class.
I managed to work around it in this case using a forward declaration due to the way one of the classes is laid out (class1 actually looks more like this):
- class Class1
-
{
-
struct Data {
-
ClassB m_classB;
-
int someMoreData;
-
};
-
-
Data * data;
-
};
I can redefine
data as a pointer to a ClassB object and do some ugly pointer arithmetic to get at the someMoreData member of the struct, which works mainly because I don't need to create objects of Class1, just interface with them.
But I expect this kind of issue comes up occassionally and I am curious how people solve it.