


#include <iostream>using namespace std;
class Per
{
private:string name;int age;double *hight;
public:Per(string name,int age,double hight):name(name),age(age),hight(new double(hight)){cout << "Per::的有参构造函数" << endl;}Per(const Per &other):name(other.name),age(other.age),hight(new double(*other.hight)){cout << "Per::拷贝构造函数" << endl;}~Per(){delete hight;hight = nullptr;cout << "Per::析构函数" << endl;}Per &operator=(const Per &other){if(this!=&other){this->name=other.name;this->age=other.age;this->hight=new double(*(other.hight));}cout << "Per::拷贝赋值函数" << endl;return *this;}};
class Stu
{
private:double score;Per p1;
public:Stu():score(0),p1("",0,0){cout << "Stu::无参构造函数" << endl;}Stu(double score,string name,int age,double hight):score(score),p1(name,age,hight){cout << "Stu::有参构造函数" << endl;}~Stu(){cout << "Stu::析构函数" << endl;}Stu(const Stu &other):score(other.score),p1(other.p1){cout << "Stu::拷贝赋值函数" << endl;}Stu &operator=(const Stu &other){if(this!=&other){this->score=other.score;this->p1=other.p1;}cout << "Stu::拷贝赋值函数" << endl;return *this;}
};
int main()
{Stu s;Stu s1(99.5,"张三",18,1.75);Stu s2(s1);s=s1;return 0;
}