多重继承的构造函数出错
#include<iostream>#include<string>
using namespace std;
class Human
{
public:
Human(string a,string b,int c)
{
name=a;
sex=b;
age=c;
}
void show()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
}
string name,sex;
int age;
};
class Teacher:public Human
{
public:
Teacher(string a,string b,int c,string d):Human(a,b,c)
{
title=d;
}
void show()
{
Human::show();
cout<<"title:"<<title<<endl<<endl;
}
private:
string title;
};
class Cader:public Human
{
public:
Cader(string a,string b,int c,string d):Human(a,b,c)
{
position=d;
}
void show()
{
Human::show();
cout<<"position:"<<position<<endl<<endl;
}
string position;
};
class TeacherCader:public Teacher,public Cader
{
public:
TeacherCader(string a,string b,int c,string d,string e):Human(a,b,c),Teacher(a,b,c,d),Cader(a,b,c,e){};
void show()
{
Teacher::show();
cout<<"position:"<<position<<endl<<endl;
}
};
int main()
{
Teacher aa("张三",48,"男","教授");
aa.show();
Cader bb("李四",55,"男","校长");
bb.show();
TeacherCader cc("王五",45"女","教授","院长");
cc.show();
return 0;
}