#include <string>
#include <iostream>
using namespace std;
class Teacher{
public :
Teacher(string nam,int a,char s,string tit);
void display();
protected :
string name;
int age;
char sex;
string title;
};
Teacher::Teacher(string nam,int a,char s,string tit):
name(nam),age(a),sex(s),title(tit){}
void Teacher::display(){
cout<<"name"<<name<<endl;
cout<<"age"<<age<<endl;
cout<<"sex"<<sex<<endl;
cout<<"title"<<title<<endl;
}
class Cadre{
public :
Cadre(string nam,int a,char s,string p);
void display();
protected :
string name;
int age;
char sex;
string post;
};
Cadre::Cadre(string nam,int a,char s,string p):
name(nam),age(a),sex(s),post(p){}
void Cadre::display(){
cout<<"name"<<name<<endl;
cout<<"age"<<age<<endl;
cout<<"sex"<<sex<<endl;
cout<<"post"<<post<<endl;
}
class Person : public Teacher,public Cadre
{
public :
Person(string nam,int a,char s , string tit,string p ,float w );
void show ();
private :
float wage;
};
Person::Person(string nam,int a,char s,string t,string p,float w):
Teacher(nam,a,s,t),Cadre(nam,a,s,p),wage(w){}
void Person::show(){
Teacher::display();
cout<<"post :"<<Cadre::post<<endl;
cout<<"wages :"<<wage<<endl;
}
int main(){
Person tg("wang",24,'f',"assistant","professor");
tg.show();
return 0;
}
编译后提示:
Compiling...
09.cpp
e:\exercise\391\09.cpp(78) : error C2661: 'Person::Person' : no overloaded function takes 5 parameters
Error executing cl.exe.
09.obj - 1 error(s), 0 warning(s)
该如何修改?谢谢各位达人