5.4

#include <iostream>
#include<string>
using namespace std;
class Person {
public:
int age;
Person(int age) {
this->age = age;
}
Person& aaa(Person& p) {
this->age += p.age;
return *this;
}
};
void test01() {
Person p(10);
cout << p.age << endl;
}
void test02() {
Person p1(5);
Person p2(10);
Person p3(22);
p2.aaa(p1).aaa(p3);
cout << p2.age << endl;
}
int main() {
test02();
system("pause");
return 0;
}

posted @ 2023-05-04 20:51  刘梦磊  阅读(72)  评论(0)    收藏  举报