#include <iostream>
using namespace std;
class Per
{
private:
string name;
int age;
double *hight;
double *weight;
public:
Per()
{
cout << "调用了Per无参构造函数" << endl;
}
Per(string name,int age,double hight, double weight):name(name),age(age),hight(new double (hight)),weight(new double (weight))
{
cout << "调用了Per有参构造函数" << endl;
}
~Per()
{
cout << "调用了析构函数" << endl;
}
Per(const Per &other):name(other.name),age(other.age),hight(other.hight),weight(other.weight)
{
cout << "调用了拷贝函数" << endl;
}
};
class Stu
{
private:
int score;
Per p1;
public:
Stu()
{
cout << "调用了Stu无参构造函数" << endl;
}
Stu(int score,Per p1): score(score),p1(p1)
{
cout << "调用了Stu有参构造函数" << endl;
}
~Stu()
{
cout << "调用了Stu析构函数" << endl;
}
};
int main()
{
Per p;
Per p1("wang",19,172,60);
Per p2=p1;
Stu S1;
Stu s2(90,p1);
return 0;