已解决
QT作业三
来自网友在路上 161861提问 提问时间:2023-10-12 03:02:06阅读次数: 61
最佳答案 问答题库618位专家为你答疑解惑
1、思维导图
https://www.zhixi.com/view/9e899ee0
2、作业
#include <iostream>using namespace std;class Per
{
private:string name;int age;int *h;int *w;
public://构造函数Per(string name,int age,int h,int w):name(name),age(age),h(new int (h)),w(new int (w)){cout << "Per:构造函数->" << this << endl;}//析构函数~Per(){cout << "Per:析构函数->" << this << endl;}//拷贝构造函数Per(const Per &other):name(other.name),age(other.age),h(other.h),w(other.w){cout << "Per:拷贝构造函数" << this << endl;}
};class Stu
{
private:int grade;Per p1;
public://构造函数Stu(int grade,Per p1):grade(grade),p1(p1){cout << "Stu:构造函数->" << this << endl;}//析构函数~Stu(){cout << "Stu:析构函数->" << this << endl;}//拷贝构造函数Stu(const Stu &other):grade(other.grade),p1(other.p1){cout << "Stu:拷贝构造函数->" << this << endl;}
};int main()
{Per p1("zhangsan",20,170,120);Stu s1(90,p1);return 0;
}
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"QT作业三":http://eshow365.cn/6-19063-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!