#include <iostream>
#include <cstring>
using namespace std;
class Teacher
{
protected:
string name;
int sex;
int age;
string address;
int phone;
string title;
public:
Teacher():name(0),sex(0),age(0),address(0),phone(0),title(0){};
Teacher(string name,int sex,int age,string address,int phone,string title);
void display();
};
Teacher::Teacher(string nam,int se,int ag,string add,int pho,string tit):name(nam),sex(se),age(ag),address(add),phone(pho),title(tit){};
void Teacher::display()
{
cout<<"姓名:"<<name<<" "<<"性别:"<<sex<<" "<<"年龄:"<<age<<" "<<"地址:"<<address<<" "<<"电话:"<<phone<<" "<<"职称"<<title;
}
class Cadre
{
protected:
string name;
int sex;
int age;
string address;
int phone;
string post;
public:
Cadre():name(0),sex(0),age(0),address(0),phone(0),post(0){};
Cadre(string name,int sex,int age,string address,int phone,string post);
void display();
};
Cadre::Cadre(string nam,int se,int ag,string add,int pho,string pos):name(nam),sex(se),age(ag),address(add),phone(pho),post(pos){};
void Cadre::display()
{
cout<<name<<" "<<sex<<" "<<age<<" "<<address<<" "<<phone<<" "<<post;
}
class Teacher_Cadre:public Teacher,public Cadre
{
protected:
double wages;
public:
Teacher_Cadre(string nam,int se,int ag,string add,int pho,string pos,string tit,double wage);
void show();
};
Teacher_Cadre::Teacher_Cadre(string nam,int se,int ag,string add,int pho,string pos,string tit,double wage):Teacher(nam,se,ag,add,pho,tit),Cadre(nam,se,ag,add,pho,pos){wages=wage;};
void Teacher_Cadre::show()
{
Teacher::display();
cout<<"职务:"<<post<<" "<<"工资:"<<wages<<endl;
}
int main()
{
Teacher_Cadre te_ca("Wang-li",0,50,"135 Beijing Road,Shanghai",61234567,"president","prof.",1534.5);
te_ca.show( );
return 0;
}
第12周项目1-教师兼干部类
最新推荐文章于 2021-06-30 16:54:23 发布