/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作 者:徐凯旋
* 完成日期:2013 年 5 月 26 日
* 版 本 号:v1.0
*/
#include<iostream>
#include<string>
using namespace std;
class Teacher
{
public:
Teacher(string n,int a,char s,string ad,string t,string ti);
void display();
private:
string name;
int age;
char sex;
string add;
string tel;
string title;
};
Teacher::Teacher(string n,int a,char s,string ad,string t,string ti):name(n),age(a),sex(s),add(ad),tel(t),title(ti){ }
void Teacher::display()
{
cout<<"name:"<<name<<endl;
cout<<"age:"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"title:"<<title<<endl;
cout<<"address:"<<add<<endl;
cout<<"tel:"<<tel<<endl;
}
class Cadre
{
public:
Cadre(string n,int a,char s,string ad,string t,string p);
void display();
private:
string name;
int age;
char sex;
string add;
string tel;
string post;
};
Cadre::Cadre(string n,int a,char s,string ad,string t,string p)
{
name=n;
age=a;
sex=s;
add=ad;
tel=t;
post=p;
}
void Cadre::display()
{
cout<<"name:"<<name<<endl;
cout<<"age"<<age<<endl;
cout<<"sex:"<<sex<<endl;
cout<<"post:"<<post<<endl;
cout<<"address:"<<add<<endl;
cout<<"tel:"<<tel<<endl;
}
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w);
void show();
private:
string name;
int age;
char sex;
string add;
string tel;
int wages;
};
Teacher_Cadre::Teacher_Cadre(string n,int a,char s,string ad,string t,string ti,string p,int w):Teacher(n,a,s,ad,t,ti),Cadre(n,a,s,ad,t,p),wages(w){ }
void Teacher_Cadre::show()
{
Teacher::display();
//cout<<"post:"<<Cadre::post<<endl;
cout<<"wages:"<<wages<<endl;
}
int main()
{
Teacher_Cadre te_ca("Wang-li",50,'f',"135 Beijing Road,Shanghai","(021)61234567","president","prof.",1534);
te_ca.show( );
system("PAUSE");
return 0;
}
运行结果: