一 . 思维导图
![请添加图片描述](https://i-blog.csdnimg.cn/blog_migrate/950541f19eac1f352921dca5e6dcd3f5.png)
二.
#include <iostream>
using namespace std;
class Person
{
private:
int age;
int p;
public:
//无参构造
Person()
{
age = 0;
p = 0;
}
//有参构造
Person(int age,int p):age(age), p(p){}
//拷贝构造函数
Person(Person &other) {
this->age = other.age;
this->p = other.p;
}
//拷贝赋值函数
Person &operator=(const Person &other){
this->age = other.age;
this->p = other.p;
return *this;
}
//析构函数
~Person(){
}
Person operator+(Person &p) {
Person temp;
temp.age = this->age + p.age;
temp.p = this->p + p.p;
return temp;
}
Person operator-(Person &p) {
Person temp;
temp.age = this->age - p.age;
temp.p = this->p - p.p;
return temp;
}
Person operator*(Person &p) {
Person temp;
temp.age = this->age * p.age;
temp.p = this->p * p.p;
return temp;
}
Person operator/(Person &p) {
Person temp;
temp.age = this->age / p.age;
temp.p = this->p / p.p;
return temp;
}
};
int main()
{
return 0;
}