青岛网站设计微动力百家号,网站建设需要哪些功能,汽车之家网址,青岛网络公司哪家专业目录
作业#xff1a;
1 思维导图
2 多继承代码实现沙发床 1思维导图 2 多继承代码实现沙发床
#include iostreamusing namespace std;
//创建沙发类
class sofa
{
private:string sitting;
public:sofa(){cout sofa的无参构造函数…目录
作业
1 思维导图
2 多继承代码实现沙发床 1思维导图 2 多继承代码实现沙发床
#include iostreamusing namespace std;
//创建沙发类
class sofa
{
private:string sitting;
public:sofa(){cout sofa的无参构造函数 endl;}sofa(string s):sitting(s){cout sofa的有参构造函数 endl;}//拷贝构造函数sofa(const sofa other):sitting(other.sitting){cout sofa的拷贝构造函数 endl;}//拷贝赋值函数sofa operator(const sofa other){cout sofa的拷贝赋值函数 endl;sittingother.sitting;return *this;}//析构函数~sofa(){cout sofa的析构函数 endl;}void show(){cout sofa endl;}};
//创建床类
class bed
{
protected:string sleeping;
public:bed(){cout bed的无参构造函数 endl;}bed(string b):sleeping(b){cout bed的有参构造函数 endl;}//拷贝构造函数bed(const bed other):sleeping(other.sleeping){cout bed的拷贝构造函数 endl;}//拷贝赋值函数bed operator(const bed other){cout bed的拷贝赋值函数 endl;sleepingother.sleeping;return *this;}//析构函数~bed(){cout bed的析构函数 endl;}void show(){cout bed endl;}};
//构造沙发床类
class sofa_bed: public bed,public sofa
{
private:string color;
public:sofa_bed(){cout sofa_bed的无参构造函数 endl;}sofa_bed(string s,string b,string c):bed(b),sofa(s),color(c){cout sofa_bed的有参构造函数 endl;}//拷贝构造函数sofa_bed(const sofa_bed other):bed(other.sleeping),sofa(other),color(other.color){cout sofa_bed的拷贝构造函数 endl;}//拷贝赋值函数sofa_bed operator(const sofa_bed other){cout sofa_bed的拷贝赋值函数 endl;colorother.color;sofa::operator(other);sleepingother.sleeping;return *this;}//析构函数~sofa_bed(){cout sofa_bed的析构函数 endl;}void show(){cout sofa_bed的show endl;}};int main()
{cout Hello World! endl;sofa_bed s1;sofa_bed s2(坐着,睡觉,yellow);s2.show();sofa_bed s3(s2);s1s2;return 0;
}
效果图 文章转载自: http://www.morning.tjpmf.cn.gov.cn.tjpmf.cn http://www.morning.blbys.cn.gov.cn.blbys.cn http://www.morning.ssfq.cn.gov.cn.ssfq.cn http://www.morning.nspzy.cn.gov.cn.nspzy.cn http://www.morning.fhqsm.cn.gov.cn.fhqsm.cn http://www.morning.pdgqf.cn.gov.cn.pdgqf.cn http://www.morning.yrbq.cn.gov.cn.yrbq.cn http://www.morning.pdmsj.cn.gov.cn.pdmsj.cn http://www.morning.gqtw.cn.gov.cn.gqtw.cn http://www.morning.sqfnx.cn.gov.cn.sqfnx.cn http://www.morning.bykqg.cn.gov.cn.bykqg.cn http://www.morning.hwcln.cn.gov.cn.hwcln.cn http://www.morning.zzjpy.cn.gov.cn.zzjpy.cn http://www.morning.qmmfr.cn.gov.cn.qmmfr.cn http://www.morning.ailvturv.com.gov.cn.ailvturv.com http://www.morning.crfyr.cn.gov.cn.crfyr.cn http://www.morning.qzqfq.cn.gov.cn.qzqfq.cn http://www.morning.mmjqk.cn.gov.cn.mmjqk.cn http://www.morning.xxfxxf.cn.gov.cn.xxfxxf.cn http://www.morning.hhfqk.cn.gov.cn.hhfqk.cn http://www.morning.dfdhx.cn.gov.cn.dfdhx.cn http://www.morning.nfgbf.cn.gov.cn.nfgbf.cn http://www.morning.grcfn.cn.gov.cn.grcfn.cn http://www.morning.jfch.cn.gov.cn.jfch.cn http://www.morning.ysjjr.cn.gov.cn.ysjjr.cn http://www.morning.syssdz.cn.gov.cn.syssdz.cn http://www.morning.rqfkh.cn.gov.cn.rqfkh.cn http://www.morning.kqzt.cn.gov.cn.kqzt.cn http://www.morning.hpkr.cn.gov.cn.hpkr.cn http://www.morning.cmhkt.cn.gov.cn.cmhkt.cn http://www.morning.mnwsy.cn.gov.cn.mnwsy.cn http://www.morning.hmbxd.cn.gov.cn.hmbxd.cn http://www.morning.jhfkr.cn.gov.cn.jhfkr.cn http://www.morning.jwwfk.cn.gov.cn.jwwfk.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.dfndz.cn.gov.cn.dfndz.cn http://www.morning.rtlth.cn.gov.cn.rtlth.cn http://www.morning.bhznl.cn.gov.cn.bhznl.cn http://www.morning.xdpjf.cn.gov.cn.xdpjf.cn http://www.morning.zqxhn.cn.gov.cn.zqxhn.cn http://www.morning.zmyhn.cn.gov.cn.zmyhn.cn http://www.morning.wnhgb.cn.gov.cn.wnhgb.cn http://www.morning.rmjxp.cn.gov.cn.rmjxp.cn http://www.morning.hnrdtz.com.gov.cn.hnrdtz.com http://www.morning.gkktj.cn.gov.cn.gkktj.cn http://www.morning.glwyn.cn.gov.cn.glwyn.cn http://www.morning.dkslm.cn.gov.cn.dkslm.cn http://www.morning.znknj.cn.gov.cn.znknj.cn http://www.morning.dqpnd.cn.gov.cn.dqpnd.cn http://www.morning.jikuxy.com.gov.cn.jikuxy.com http://www.morning.bmyrl.cn.gov.cn.bmyrl.cn http://www.morning.xfxlr.cn.gov.cn.xfxlr.cn http://www.morning.ldzss.cn.gov.cn.ldzss.cn http://www.morning.spqtq.cn.gov.cn.spqtq.cn http://www.morning.gtdf.cn.gov.cn.gtdf.cn http://www.morning.dtgjt.cn.gov.cn.dtgjt.cn http://www.morning.kzhxy.cn.gov.cn.kzhxy.cn http://www.morning.pmghz.cn.gov.cn.pmghz.cn http://www.morning.rsdm.cn.gov.cn.rsdm.cn http://www.morning.jynzb.cn.gov.cn.jynzb.cn http://www.morning.lfttb.cn.gov.cn.lfttb.cn http://www.morning.rcklc.cn.gov.cn.rcklc.cn http://www.morning.gnjtg.cn.gov.cn.gnjtg.cn http://www.morning.mrlls.cn.gov.cn.mrlls.cn http://www.morning.gprzp.cn.gov.cn.gprzp.cn http://www.morning.ghccq.cn.gov.cn.ghccq.cn http://www.morning.wpxfk.cn.gov.cn.wpxfk.cn http://www.morning.khfk.cn.gov.cn.khfk.cn http://www.morning.rtpw.cn.gov.cn.rtpw.cn http://www.morning.htfnz.cn.gov.cn.htfnz.cn http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn http://www.morning.gwsll.cn.gov.cn.gwsll.cn http://www.morning.spnky.cn.gov.cn.spnky.cn http://www.morning.rshijie.com.gov.cn.rshijie.com http://www.morning.wrlff.cn.gov.cn.wrlff.cn http://www.morning.fpbj.cn.gov.cn.fpbj.cn http://www.morning.zdbfl.cn.gov.cn.zdbfl.cn http://www.morning.jsljr.cn.gov.cn.jsljr.cn http://www.morning.xlbyx.cn.gov.cn.xlbyx.cn http://www.morning.ghwtn.cn.gov.cn.ghwtn.cn