当前位置: 首页 > wzjs >正文

上海住房和城乡建设部网站非国产手机浏览器

上海住房和城乡建设部网站,非国产手机浏览器,长沙网站建设网站,仿团购网站模板沙发床的多继承 多继承代码实现沙发床沙发床继承于沙发和床 代码&#xff1a; #include <iostream>using namespace std;//封装 沙发 类 class Sofa { private:string sitting;double *size; public://无参构造函数Sofa() {cout << "Sofa::无参构造函数&quo…
 沙发床的多继承
  • 多继承代码实现沙发床
  • 沙发床继承于沙发和床
 代码:
#include <iostream>using namespace std;//封装 沙发 类
class Sofa
{
private:string sitting;double *size;
public://无参构造函数Sofa() {cout << "Sofa::无参构造函数" << endl;}//有参构造函数Sofa(string s,double si):sitting(s),size(new double(si)){cout << "Sofa::有参构造函数" << endl;}//拷贝构造函数Sofa(const Sofa &other):sitting(other.sitting),size(other.size){cout << "Sofa::拷贝构造函数" << endl;}//拷贝赋值函数Sofa &operator=(const Sofa &other){if(this != &other){cout << "Sofa::拷贝赋值函数" << endl;this->sitting = other.sitting;this->size = other.size;}return *this;}//析构函数~Sofa(){delete(size);size = nullptr;cout << "Sofa::析构函数" << endl;}void show(){cout << sitting << "  " << *size << endl;}
};//封装 床 类
class Bed
{
private:string sleep;
public://无参构造函数Bed() {cout << "Bed::无参构造函数" << endl;}//有参构造函数Bed(string s):sleep(s){cout << "Bed::有参构造函数" << endl;}//拷贝构造函数Bed(const Bed &other):sleep(other.sleep){cout << "Bed::拷贝构造函数" << endl;}//拷贝赋值函数Bed &operator=(const Bed &other){cout << "Bed::拷贝赋值函数" << endl;this->sleep = other.sleep;return *this;}//析构函数~Bed(){cout << "Bed::析构函数" << endl;}void show(){cout << sleep << endl;}
};//封装 沙发床 类 共有继承沙发和床
class Sofa_bed:public Sofa,public Bed
{
private:string color;
public://无参构造函数Sofa_bed(){cout << "Sofa_bed::无参构造函数" << endl;}//有参构造函数Sofa_bed(string s, double size,string sl, string c):Sofa(s,size), Bed(sl),color(c){cout << "Sofa_bed::有参构造函数" << endl;}//拷贝构造函数     深拷贝Sofa_bed(const Sofa_bed &other):Sofa(other),Bed(other),color(other.color){cout << "Sofa_bed::拷贝构造函数" << endl;}//拷贝赋值函数Sofa_bed &operator=(const Sofa_bed &other){cout << "Sofa::拷贝赋值函数" << endl;this->color = other.color;this->Sofa::operator=(other);this->Bed::operator=(other);return *this;}//析构函数~Sofa_bed(){cout << "Sofa_bed::析构函数" << endl;}void show(){Sofa::show();Bed::show();cout << color << endl;}
};
int main()
{Sofa_bed sb("可以坐", 180, "可以睡", "灰不溜秋");cout << "++++++++++++++++++++++++++++++++++++++" << endl;sb.Sofa::show();cout << "++++++++++++++++++++++++++++++++++++++" << endl;sb.Bed::show();cout << "++++++++++++++++++++++++++++++++++++++" << endl;sb.show();cout << "++++++++++++++++++++++++++++++++++++++" << endl;return 0;
}
运行效果图:

思维导图

http://www.dtcms.com/wzjs/89055.html

相关文章:

  • 网站整合营销建设网络培训心得体会
  • 政府机关网站建设的依据百度推广首次开户需要多少钱
  • 淘宝客合伙人网站建设吉林关键词优化的方法
  • 唯样商城网站百度爱采购优化排名软件
  • 网站开发容易学吗广告网站留电话
  • 评析网站建设报价单百度一下 你就知道官网
  • 大型大型网站建设方案产品怎样推广有效
  • wordpress网站文章被插入很多黑链接无锡seo公司找哪家好
  • 福永专业外贸网站建设公司优化模型
  • 建设微网站需要多少钱广点通推广登录入口
  • 设计商城商务网站站长网站统计
  • 玉环城乡建设规划局网站电商运营
  • 广州门户网站制作电商沙盘seo裤子关键词
  • 如何仿做网站seo经理招聘
  • 北京哪个公司做网站app推广80元一单
  • 为企业规划一个网站优化大师win10
  • 济南公司做网站的价格seo百度首页排名业务
  • 谈谈对电子商务网站建设的理解军事新闻
  • dw做动态网站珠海百度seo
  • 邵阳做网站价格杭州seo网站优化
  • wordpress 文章页模板网页seo搜索引擎优化
  • 公司网站的重要性营销网络图
  • 做详情页的网站产品网络营销分析
  • 浅谈学校网站建设网络广告代理
  • 积分兑换商城网站建设seo关键词优化软件官网
  • 房山网站制作微信推广平台怎么做
  • 书法网站建设预防电信网络诈骗
  • 门户网站开发需求今日疫情最新消息全国31个省
  • 高端定制网站建设站长统计幸福宝
  • 如何做自媒体和网站签约赚点击企业网站建设需要多少钱