编写一个程序,定义一个教师类,由教师类派生出讲师类,教授类。教师 的工资分别由基本工资,课时费和

2020-10-02 社会 182阅读
#include using namespace std; class teacher{ public: teacher(double b,double t,double a):basic(b),tuitionfee(t),allowance(a){} virtual double salary(){ return this->basic+this->tuitionfee+this->allowance; } protected: //基本工资 double basic; //课时费 double tuitionfee; //津贴 double allowance; }; //讲师 class lecturer:public teacher{ public: lecturer(double b,double t,double a):teacher(b,t,a){} double salary(){ return this->basic+this->tuitionfee+this->allowance; } }; //副教授 class associateprof:public teacher{ public: associateprof(double b,double t,double a):teacher(b,t,a){} double salary(){ return this->basic+this->tuitionfee+this->allowance; } }; //教授 class fullprof:public teacher{ public: fullprof(double b,double t,double a):teacher(b,t,a){} double salary(){ return this->basic+this->tuitionfee+this->allowance; } }; int main(){ teacher *t; lecturer l(800,40,1300); t=&l; cout
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com