#include <iostream>
using namespace std;
class Teacher
{
public:
Teacher(string,int,char,string,string,string);
void display();
private:
string name;
int age;
char sex;
string address;
string phone;
string title;
};
Teacher::Teacher(string name,int age,char sex,string address,string phone,string titile)
:name(name),age(age),sex(sex),address(address),phone(phone),title(title){}
void Teacher::display()
{
cout << name << endl;
cout << age << endl;
cout << sex << endl;
cout << address << endl;
cout << phone << endl;
cout << title << endl;
}
class Cadre
{
public:
Cadre(string name,int age,char sex,string address,string phone,string post);
void display();
private:
string name;
int age;
char sex;
string address;
string phone;
protected:
string post;
};
Cadre::Cadre(string name,int age,char sex,string address,string phone,string post)
:name(name),age(age),sex(sex),address(address),phone(phone),post(post){}
void Cadre::display()
{
cout << name << endl;
cout << age << endl;
cout << sex << endl;
cout << address << endl;
cout << phone << endl;
cout << post << endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string name,int age,char sex,string address,string phone,string post,string title,int wages):
Teacher(name,age,sex,address,phone,title),
Cadre(name,age,sex,address,phone,post),wages(wages)
{}
void show();
private:
int wages;
};
void Teacher_Cadre::show()
{
Teacher::display();
cout << "post:" << Cadre::post<< "wages:" << wages << endl;
}
int main()
{
Teacher_Cadre tc("xiaopeng",26,'M',"zhengzhou","13526568417","ceo","teacher",2300);
tc.show();
system("pause");
return 0;
}
|