1.
CDinPlanResult::CDinPlanResult(CDinCmdPtr Ptr)
^
comm.h
using namespace
{
class CSon;
struct sonCmdPlanResult
{
CSon *ptrSon;
}
}
father.h
#include "comm.h"
class CCmdLookAheadPlannerResult
{
};
son.h
class CSon :public CFather
{
};
则编译时会报错:
error: reference to 'CSon' is ambiguous(模糊的)
原因与编译顺序有关,
如果先编译comm.h
发现前向声明在namespace里面,则认为Class Cson是命名空间的一个类,
然后等编译son.h时又发现一个Cson 类,则编译器认为两者重名,不知道该用哪个了,模糊了
解决办法:
将comm.h
中对CSon的前向声明挪到namespce之外
comm.h
class CSon;
using namespace
{
struct sonCmdPlanResult
{
CSon *ptrSon;
}
}
即可解决。