第12周项目1-教师兼干部类

#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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值