1009HW

using namespace std;
class Per
{
private:
    string name;
    int age;
    int *height;
    int *weight;
public:
    Per()
    {
        cout << "per无参构造" << endl;
    }
    Per(string name,int age, int *height,int *weight):name(name),age(age),height(height),weight(weight)
    {
        cout << "per有参构造" << endl;
    }
    ~Per()
    {
        cout << this << ":per析构成功" << endl;
    }
    Per(const Per &other):name(other.name),age(other.age),height(other.height),weight(other.weight)
    {
        cout << this << "per拷贝构造" << 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 << this << ":stu析构成功" << endl;
    }
    Stu(const Stu &other):score(other.score),p1(other.p1)
    {
        cout << "stu拷贝构造" << endl;
    }


};

1009HW_第1张图片

你可能感兴趣的:(c++,开发语言)