I might be mistaken but forward declaration only works in the case that the header being defined only uses pointers to the other needed class. Take for instance:
Code:
//forward declaration
class classA;
class classB
{
protected:
classA *m_ptr;
public:
...
};
This will work since you define only a ptr to classA so classA object size is not important since you won't be allocating a classA object on stack but only a pointer to it and a pointer is always the same size, if on the other hand you had a class:
Code:
//forward declaration
class classA;
class classB
{
protected:
classA m_obj;
...
};
Now this wouldn't work without including the header file for classA since for creating an instance of classB you'll need to allocate space for an instance of classA.
Cheers