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

/*要求:运用多态性与虚函数计算工资总工资=基本工资+每节课工资*上课总数教授:基本工资5000每节课50补贴;副教授:基本工资3000每节课30补贴;普通教师:基本工资... /*要求:运用多态性与虚函数 计算工资 总工资=基本工资+每节课工资*上课总数 教授:基本工资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,Totalcourse);
}
};
class AProfessor:public Teacher
{
public:
AProfessor()
{
Basewage=3000;
wagepercourse=30;
cout<<"Please intput the total course !\n";
cin>>Totalcourse;
}
virtual void wage()
{
Computwage(3000,30,Totalcourse);
}
};
class NormalTeacher:public Teacher
{
public:
NormalTeacher()
{
Basewage=2000;
wagepercourse=20;
cout<<"Please intput the total course !\n";
cin>>Totalcourse;
}
virtual void wage()
{
Computwage(2000,20,Totalcourse);
}
};
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(professor);
}
else if(post==2)
{
Aprofessor a;
t=&a;
t->wage();
t->show(Aprofessor);
}
else if(post==3)
{
Normalteacher n;
t=&n;
t->wage();
t->show(Normalteacher);
}
else
{
cout<<"Error !!! There have no such option!!!\nPlease select again !!!\n";
goto star;
}
}
展开
 我来答
梦想窗外
2009-05-31 · TA获得超过1588个赞
知道大有可为答主
回答量:1180
采纳率:0%
帮助的人:1547万
展开全部
请紧记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 !!!\n";
goto star;
}
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式