so I just can't work out my circular inclusions. Can anyone give me a hand? I know I need to be pre-declaring my classes, but I can not work out the combination (mostly guess-work though). OtherClass
is meant to be like a container for ParentClass
and its children.
My current class setup is along the lines of this:
OtherClass.h
class ParentClass; // includes
class ChildClass;
class OtherClass
{
ParentClass* parent;
ChildClass* child;
}
ParentClass.h
class OtherClass;
class ParentClass
{
OtherClass* other;
}
ChildClass.h
#include "ParentClass.h";
#include "OtherClass.h";
class ChildClass: public ParentClass
{
other->foo(); // Using OtherClass pointer declared in parent.
}
For that approach above, I am getting Member access into incomplete type 'ParentClass'
.
This probably also needs to be expandable, as I'm sure in the future there will be more child classes of ChildClass
.