急急急!!!在线等!!C++改错!!

来源:百度知道 编辑:UC知道 时间:2024/06/15 13:26:26
/*要求:运用多态性与虚函数 计算工资 总工资=基本工资+每节课工资*上课总数 教授:基本工资5000 每节课50补贴; 副教授:基本工资3000 每节课30补贴; 普通教师:基本工资2000 每节课20补贴;我定义Aprofseeor 副教授; NormalTeacher 普通教师*/
#include<iostream>
using namespace std;
class Teacher
{
protected:
int Basewage,Totalwage,Totalcourse,wagepercourse;
char Post;
public:
virtual void wage()=0;
int Computwage(int Basewage,int wagepercourse,int Totalcourse)
{
Totalwage=Basewage+wagepercourse*Totalcourse;
return Totalwage;
}
void show(char post)
{
cout<<"The total wage of the"<<Post<<"is"<<Totalwage<<endl;
}
};
class Professor:public Teacher
{
public:
Professor()
{
Basewage=5000;
wagepercourse=50;
cout<<"Please intput the total course !\n";
cin>>Totalcourse;
}
virtual void wage()
{
Computwage(5000,50,Tot

请紧记C语言中区分大小写,例如post和Post是不同的两个词。
void show(char post)
{
cout<<"The total wage of the"<<post<<"is"<<Totalwage<<endl;
}

void main()
{
char post;
Teacher *t;
star:cout<<"************Please select the post of the teacher**************\n";
cout<<"1 for Professor 2 for A-Professor 3 for Normal-teacher\n";
cin>>post;
if(post=='1')
{
Professor p;
t=&p;
t->wage();
t->show(post);
}
else if(post=='2')
{
AProfessor a;
t=&a;
t->wage();
t->show(post);
}
else if(post=='3')
{
NormalTeacher n;
t=&n;
t->wage();
t->show(post);
}
else
{
cout<<"Error !!! There have no such option!!!\nPlease select again !!