I am relatively new to C++, and I am trying to write a simple 2D engine. However, there is a problem with the current structure which was okay in other languages (AS3 etc). I have two classes, one called DisplayObject, and another one called DisplayObjectContainer. DisplayObjectContainer is a subclass of DisplayObject, but DisplayObject has a pointer to a DisplayObjectContainer parent as property. I can't figure out a way to properly include each other in their files. I can't forward declare DisplayObjectContainer in DisplayObject because I need to access DisplayObjectContainer's methods in DisplayObject.
DisplayObject:
class DisplayObject
{
public:
DisplayObjectContainer *parent;
...
...this->parent->globalTransform...
...
DisplayObjectContainer:
class DisplayObjectContainer : public DisplayObject
{
public:
DisplayObjectContainer();
virtual ~DisplayObjectContainer();
protected:
private:
};
Any help would be appreciated. Thanks!