For example, class A has a member of class B. In general, in order to minimize compilation dependencies, we often make class A include B pointer and pre-declare class B in the declaration of class A. It looks like this:
class B
{
....
};
class B;
class A
{
B*b;
A();
...
};
#include "B.h"
A::A()
{
b=new B();
...
};
But now I have a question: if class B is defined using typedef as follows:
typedef class
{
....
}B;
The previous previously declared method will not work in this case. How should I pre-declare class B in Ah?
source
share