forward-declarations

Alternative to forward declarations when you don't want to #include

I usually, almost without thinking anymore, use forward declarations so that I won't have to include headers. Something along this example: //----------------------- // foo.h //----------------------- class foo { foo(); ~foo(); }; //----------------------- // bar.h //----------------------- class foo; // forward declaration cl...

Why does forward declaration not work with classes?

int main() { B bb; //does not compile (neither does class B bb;) C cc; //does not compile struct t tt; //compiles class B {}; //HERE is the class B defination struct s { struct t * pt; }; //compiles struct t { struct s ...