#include <iostream>
#include <string>
using namespace std;
class teacher
{
public:
teacher(int a,string nam,string ho,double ip,string la);
void display1();
protected:
int age;//年龄
string name;//姓名
string home;//住址
double phone;//电话号码
string title;//职称
};
teacher::teacher(int a,string nam,string ho,double ip,string la)
{
age=a;
name=nam;
home=ho;
phone=ip;
title=la;
}
void teacher::display1()
{
cout<<"该老师信息为:"<<endl;
cout<<age<<" "<<name<<" "<<home<<" "<<phone<<" "<<title;
}
class cadre
{
public:
cadre(int a,string nam,string ho,double b,string po);
protected:
int age;//年龄
string name;
string home;//住址
double phone;//电话号码
string post;//职务
};
cadre::cadre(int a,string nam,string ho,double b,string po)
{
age=a;
name=nam;
home=ho;
phone=b;
post=po;
}
class teache_cadre: public teacher,public cadre
{
public:
teache_cadre(int,string,string,double,string,string,double);
void display();
private:
double wages;//工资
};
teache_cadre::teache_cadre(int a,string nam,string ho,double b,string la,
string po,double wa)
:teacher(a,nam,ho,b,la),
cadre(a,nam,ho,b,po),wages(wa){}
void teache_cadre::display()
{
teacher::display1();
cout<<" "<<post<<" "<<wages;
}
int main()
{
teache_cadre l1(35,"wangfang","jinan",1387654321,"jiaoshi","wu",56000);
l1.display();
}
运行结果: