首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

求未定义类型异常解决方案

2012-03-09 
求未定义类型错误解决方案已经提问过一回,上次没有说明白,这次再具体说一下。各位高手帮忙看一下如何解决。t

求未定义类型错误解决方案
已经提问过一回,上次没有说明白,这次再具体说一下。各位高手帮忙看一下如何解决。
testA.h:

#if   !defined(_a_)
#define   _a_
#include   "testB.h "
class   A{
public:
B   b;
public:
aMethod();
};
#endif

testA.cpp:

#include   "testA.h "
A::aMethod(){

}

testB.h
#if   !defined(_b_)
#define   _b_
//#   include   "testA.h " <--这个Include了也不好使
class   A;
class   B{
public:
A   *   a;
public:
setA(A*a);
bMethod();
};
#endif

testB.cpp
#include   "testB.h "
B::setA(A*a){
this-> a=a;
}
B::bMethod(){
a-> aMethod();
}

编译类A没问题,编译类B有错误:
testB.cpp
testB.cpp(6)   :   error   C2027:   使用了未定义类型“A”
                d:\dxsdk\Extras\DirectShow\Samples\C++\DirectShow\course_client2\destop   capture   filter\testB.h(4)   :   参见“A”的声明
testB.cpp(6)   :   error   C2227:   “-> aMethod”的左侧必须指向类/结构/联合


这种相互之间存在依赖关系应当如何来解决。

[解决办法]
testB.cpp
#include "testB.h "
#include "testA.h "

热点排行