Could anyone tell me why the following code fragment is not valid. I get an Undefined Structure error
The class has to store a reference to another instance of the class. Actually reference is a bad term, technically a copy, since the original version of that instance may be deleted/moved by another part of the program.Code:class MyClass { public: ........ private: MyClass instanceOfClass; };
Im assuming that the problem is something to do with c++ wanting to know the size of everything at compile time. But then how do I get around it? Like I said, I cant use a pointer, because the instance of MyClass it points to may be either deleted or moved.