信管14:多重继承示例一

仔细阅读下面程序,分析类的继续情况,重点请关注,多重继续构造函数的定义。
#include<iostream>
#include<string>
using namespace std;
class person 
{  string id_card;
   string name;	
   char sex;
 public:	
   person(string id,string na,char se)
   { id_card=id;
     name=na;
     sex=se;
   }  	 
  void print1()
   { 
	   cout<<"name:  "<<name<<endl<<"id_card:"<<id_card<<endl<<"sex:  "<<sex<<endl;
   }
};

class student:public person
{	
   string class_name;
   string profession;	
   string student_id;
 public:	
   student(string id,string na,char se,string cl,string pr,string st):person(id,na,se)
   { class_name=cl;
     profession=pr;
     student_id=st;
   }  	

  void  print2()
   { 
    cout<<"class_name: "<<class_name<<endl<<"profession: "<<profession<<endl<<"student_id: "<<student_id<<endl;
   }
};

class score
{	
    int computer;
 public:	
   score(int co)
   { computer=co;   }  	

  void print3()
   { 
     cout<<"computer: "<<computer<<endl;
   }
};

class cadre:public student,public score
{	
   string title;
   string  evaluation;	
  public:	
   cadre(string id,string na, char se,string cl,string pr,string st,int co,string ti,string ev)
	:student(id,na,se,cl,pr,st),score(co)
    { title=ti;evaluation=ev;   }  	

   void print()
   {  // person::print1();
      // student::print2();
      // score::print3();
	 cout<<"title:  "<<title<<endl<<"evaluation:  "<<evaluation<<endl;
   }
};

int main()
{	cadre cadre1("422126197104158517","mingge",'m',"computer201401","computer","20140101",99,"monitor","well");
	//cadre1.print();

        cadre1.print1();
	cadre1.print2();
	cadre1.print3();
	cadre1.print();
	system("pause");
        return 0;
}

思考:将程序中隐含的语句打开,分析程序执行结果。如果要和现在程序执行结果相同,打开隐含语句后,去掉哪些语句?尝试修改并调试执行t程序。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值