In class A contains a class B object
ClassB;
class A
{
private:
ClassB b;
}
sometimes declare classB is enough, sometimes,I have to use #include "ClassB.h", why? Any difference when using those two?
In class A contains a class B object
ClassB;
class A
{
private:
ClassB b;
}
sometimes declare classB is enough, sometimes,I have to use #include "ClassB.h", why? Any difference when using those two?
When forward declaring a class you can only use the forward declared class as a reference or pointer because at this point, the compiler is not aware of the size of this type. Here's a good stackoverflow post about what you can and cannot do with forward declarations.