struct MyB;
struct MyA: public A<MyB>{};
struct MyB: public B<MyA>{};
int main(int argc, char *argv[])
{
}
does not compile because
"main.cpp:6: error: invalid use of incomplete type ‘struct MyB’".
Basically the compiler cannot solve the loop because definition
of A depends on definition of B an viceversa.
Is there a way to sort this out?
thanks,
Rob
In general, a forward declaration is only useful if you want to reference a pointer (or reference) to the type. The compiler usually knows how large a pointer (or reference) is, but it cannot know how big a struct/class is going to be; hence the error.