#include <iostream>
using namespace std;
class Room{
friend class Stu;
private:
string name;
int age;
public:
Room(){
name = "lisi";
}
Room(string name, int age):name(name),age(age){
}
void show()const{
cout << "长城园" << endl;
}
void show(){
cout << "非长城园" << endl;
}
};
class Stu{
private:
Room *r;
public:
void show();
};
void Stu::show(){
r = new Room;
cout << r->name << endl;
delete r;
r = nullptr;
}
int main()
{
const Room r1 = Room("zhangsan", 20);
r1.show();
Room r2;
r2.show();
Stu s1;
s1.show();
return 0;
}
20240606
最新推荐文章于 2024-07-25 09:24:40 发布