#include
using namespace std;
class Person
{
public:
Person(string nam,int a,int nu)
{
name=nam;
age=a;
number=nu;
}
void display()
{
cout<<"name: "<
protected:
string name;
int age;
int number;
};
class Teacher:public Person
{
public:
Teacher(string nam,int a,int nu,string t):Person(nam,a,nu),title(t){}
void show1()
{
display();
cout<<"title: "<
protected:
string title;
};
class Cadre:public Person
{
public:
Cadre(string nam,int a,int nu,string p):Person(nam,a,nu),post(p){}
void show2()
{
display();
cout<<"post: "<
protected:
string post;
};
class Teacher_Cadre:public Teacher,public Cadre
{
public:
Teacher_Cadre(string nam,int a,int nu,string t,string p,float w):
Teacher(nam,a,nu,t),Cadre(nam,a,nu,p),wages(w){}
void show3()
{
show1();
cout<<"post: "<
protected:
float wages;
};
int main()
{
Teacher_Cadre tc("harry",36,12345,"director","manager",100000);
tc.show3();
while(1);
return 0;
}
参考一下,这个程序差不多的。下面的继承是多重继承。