c++头文件的问题
假如有a,b两个类其中a类中有b 类的一个实例,b类中有a类的一个指针这时他们的头文件该如何声明
[解决办法]
//A.h
#ifndef _A_H_
#define _A_H_
#include "b.h "
class A
{
private:
B b;
};
#endif // end of A.h
///////
//B.h
#ifndef _B_H_
#define _B_H_
class A;
class B
{
private:
A* a;
};
#endif //end of B.h