#include <iostream>
#include <string>
using namespace std;
class Teacher
{
public:
Teacher(string nam,char s,int a,string add,int p,string t);
void display();
private:
string name;
char sex;
int age;
string address;
int phone;
string title;
};
Teacher::Teacher( string nam,char s,int a,string add,int p,string t)
{
name=nam;
sex=s;
age=a;
address=add;
phone=p;
title=t;
}
void Teacher::display()
{
cout<<name<<endl;
cout<<sex<<endl;
cout<<age<<endl;
cout<<address<<endl;
cout<<phone<<endl;
cout<<title<<endl;
}
class Cadre
{
public:
Cadre(string nam,char s,int a,string add,int p, string po);
void display();
protected:
string name;
char sex;
int age;
string address;
int phone;
string post;
};
Cadre::Cadre(string nam,char s,int a,string add,int p, string po):name(nam),sex(s),age(a),address(add),phone(p),post(po){}
void Cadre::display()
{
cout<<name<<endl;
cout<<sex<<endl;
cout<<age<<endl;
cout<<address<<endl;
cout<<phone<<endl;
cout<<post<<endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string nam,char s,int a,string add,int p,string t,string po,int w):Teacher(nam,s,a,add,p,t),Cadre(nam,s,a,add,p,po),wages(w){}
void show();
private:
int wages;
};
void Teacher_Cadre::show()
{
Teacher::display();
cout<<post<<endl;
cout<<wages<<endl;
}
int main()
{
Teacher_Cadre t("xiao-ming",'f',20,"yd",1234,"ujgf","qewg",1235);
t.show();
return 0;
}
结果:
感受:呵呵