# include & lt; Iostream>
using namespace std;
The class Person;
The class Building
{
//friend void Person: : fangwen ();
Public:
Building ()
{
Room1="livingroom";
Room2="bedroom".
}
Public:
String Room1.
//private:
String Room2.
};
The class Person
{
Public:
The Person (s)
{
Build=new Building;
}
Void fangwen ()
{
Cout & lt;Cout & lt; }
Building * build;
};
Void test ()
{
The Person p1;
P1. Fangwen ();
}
Int main ()
{
test();
cin.get();
return 0;
}
I ask commented out two lines of code where is wrong? Restore comments after running under the Building into room2 cannot be accessed, I set up a friend
CodePudding user response:
Have been solved, thank you, class member friend yuan should be friend of the whole classCodePudding user response:
Bai hey hey, give me some points to discuss the c + +