using namespace std;
//class goodBoy;
class Building{
//friend class goodBoy;
friend void goodBoy::visit();
public:
Building(){
this->m_SittingRoom = "客厅";
this->m_BeddingRoom = "卧室";
}
public:
string m_SittingRoom;
private:
string m_BeddingRoom;
};
class goodBoy{
public:
goodBoy(){
build = new Building;
}
void visit(){
cout << "好朋友正在访问 " << this->build->m_SittingRoom << endl;
cout << "好朋友正在访问 " << this->build->m_BeddingRoom << endl;
}
private:
Building * build;
};
void test03(){
goodBoy * boy = new goodBoy;
boy->visit();
}
int main(){
test03();
return 0;
}
这个为什么报error: use of undeclared identifier 'goodBoy'这个错误啊;小白一枚
在这插入代码
谢谢,我重新发布了一个
@牛坤: 嘿嘿,既然这帖子没用了,给我个结贴呗,非常感谢!
你把问题再编辑一下,使用插入代码,这样子我们比较好阅读代码
– Conan-jine 4年前