error C2027:use of undefined type 'A' see declaration of 'A#includeusing namespace std;class A;class B{public :B(A * a){a->c = 5;}};class A{public:int c;void set(){B b(this);cout

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/29 16:57:40
error C2027:use of undefined type 'A' see declaration of 'A#includeusing namespace std;class A;class B{public :B(A * a){a->c = 5;}};class A{public:int c;void set(){B b(this);cout
xRj@>.j\`;_"KVJBB1LnĹBTN/P[H_tO}Y9sfά*fXaOKMWWɦ&PR- =a]?]~IlSV؎ZfT1J ӭ5JR^ l.(WNАw^hvSY/g p`N {KS

error C2027:use of undefined type 'A' see declaration of 'A#includeusing namespace std;class A;class B{public :B(A * a){a->c = 5;}};class A{public:int c;void set(){B b(this);cout
error C2027:use of undefined type 'A' see declaration of 'A
#include
using namespace std;
class A;
class B
{
public :
B(A * a){
a->c = 5;
}
};
class A
{
public:
int c;
void set()
{
B b(this);
cout

error C2027:use of undefined type 'A' see declaration of 'A#includeusing namespace std;class A;class B{public :B(A * a){a->c = 5;}};class A{public:int c;void set(){B b(this);cout
你在定义类B之前,只是声明了类A,这个声明是前向声明,在类A声明之后,定义之前,类A 是不完整类型,即已知A是一个类型,但不知道包含哪些成员.
对于不完整类型,只能定义一个A类型的指针或引用,且不能访问它的成员,因为编译器只知道有类A存在而不知道类A到底是什么.