仔细阅读下面程序,分析类的继续情况,重点请关注,多重继续构造函数的定义。
#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程序。