#include <iostream>
using namespace std;
class Per
{
string name;
int age;
int *high;
int *heigth;
public:
Per(string n,int a,int *hi,int *he);
~Per();
Per(Per &other);
//void show();
};
Per :: Per(string n,int a,int *hi,int *he):name(n),age(a),high(new int(*hi)),heigth(new int(*he))
{
cout << "Per构造函数" << endl;
}
Per :: ~Per()
{
delete high;
delete heigth;
cout << "Per析构函数" << endl;
}
Per :: Per(Per &other)
{
this->name = other.name;
this->age = other.age;
high = new int;
*high = *(other.high);
heigth = new int;
*(heigth) = *(other.heigth);
cout << "Per拷贝构造函数" << endl;
class Stu
{
int score;
Per p1;
public:
Stu(int s,string name,int age,int *high,int *heigth);
~Stu();
Stu(Stu &other);
};
Stu::Stu(int s,string name,int age,int *high,int *heigth):score(s),p1(name,age,*high,*heigth)
{
cout << "Stu构造函数" << endl;
}
Stu :: ~Stu()
{
cout << "Stu析构函数" << endl;
}
Stu :: Stu(Stu &other)
{
this->score = other.score;
p1 = new int;
*p1 = *(other.p1);
cout << "Stu拷贝构造函数" << endl;
}
int main()
{
return 0;
}