I’m creating a class named Circle and needs a public property to access its ‘parent’ Circle instance. Thus I code it like this:
class Circle {
public:
...
Circle parent;
...
}
But this gave me an error: Incomplete type is not allowed
What should I do?
That cannot be done. Consider what the memory footprint of your type would be: a
Circlecontains aCircle, so it size cannot be smaller than the innerCircle, but that size is the same as the size of the outerCircle, reaching a contradiction.Maybe you meant to store a pointer or smart pointer? That is allowed, since the size of the pointer is known by the compiler.