提示错误不明白?
# include<iostream># include<cstring>
using namespace std;
class Person{
protected:
char Name[10];
char Sex;
int Age;
public:
void Register(char *name,int age,char sex);
void ShowMe();
};
class Teacher:public Person{
char Dept[20];
int Salary;
public:
Teaher(char *name,int age,char sex,char *dept,int salary);
void ShowMe();
};
class Student:public Person{
char ID[12];
char Class[12];
public:
Student(char *name,int age,char sex,char *id,char *classid);
void ShowMe();
};
void Person::Register(char *name, int age,char sex){
strcpy(Name,name);
Sex=(sex=='m'?'m':'f');
Age=age;
}
void Person::ShowMe(){
cout<<"姓 名:"<<Name<<endl;
cout<<"性 别:"<<(Sex=='m'?"男":"女")<<endl;
cout<<"年 龄:"<<Age<<endl;
}
Teacher::Teaher(char *name,int age,char sex,char *dept,int salary){
Teacher::Register(name,age,sex);
strcpy(Dept,dept);
Salary=salary;
}
Student::Student(char *name,int age,char sex,char *id,char *classid){
Student::Register(name,age,sex);
strcpy(ID,id);
strcpy(Class,classid);
}
void Student::ShowMe(){
cout<<"学 号:"<<ID<<endl;
Person::ShowMe();
cout<<"班 级:"<<Class<<"\n\n";
}
void main(){
Teacher empl("章立早",38,'m',"电信学院",2300);
Student stdl("李木子",22,'f',"02035003","能动01");
empl.ShowMe();
stdl.ShowMe();
}
编译如下:
--------------------Configuration: PersonTeacherStudent - Win32 Debug--------------------
Compiling...
PTS.CPP
F:\vc++\vc++程序\MyObject\PersonTeacherStudent\PTS.CPP(58) : error C2661: 'Teacher::Teacher' : no overloaded function takes 5 parameters
执行 cl.exe 时出错.
PersonTeacherStudent.exe - 1 error(s), 0 warning(s)
看不懂什么意思/