请教C++高手 谁能帮我找到这到题目的源程序

来源:百度知道 编辑:UC知道 时间:2024/06/14 15:49:33
分别声明Teacher(教师)类和Cadre(干部)类,采用多重继承方式由这两个类派生出新类Teacher_Cadre(教师兼干部)。要求:
1) 在两个基类中都包含姓名、年龄、性别、地址、电话等数据成员;
2) 在类Teacher中还包含数据成员title(职称),在类Cadre中还包含数据成员post(职务)。在Teacher_Cadre类中还包含数据成员wages(工资);
3) 对两个基类中的姓名、年龄、性别、地址、电话等数据成员用相同的名字,在引用这些数据成员时,指定作用域;
4) 在类体中声明成员函数,在类外定义成员函数;
5) 在派生类Teacher_Cadre的成员函数show中调用Teacher类中的display函数,输出姓名、年龄、性别、职称、地址、电话,然后再用cout语句输出职务和工资。

#include<iostream.h>
#include<string.h>
class Base{
protected:
int age,nember;
char *name,*address,*sex;
public:Base(int a,int ne,char *n,char *ad,char *s){
age=a;
nember=ne;
name=new char[strlen(n)+1];
strcpy(name,n);
address=new char[strlen(ad)+1];
strcpy(address,ad);
sex=new char[strlen(ad)+1];
strcpy(sex,s);
}
void display1(){
cout<<"姓名:"<<name;
cout<<"电话:"<<nember;
cout<<"年龄:"<<age;
cout<<"性别:"<<sex;
cout<<"地址:"<<address;
}

};

class Teacher:virtual public Base{
char *title;
public:
Teacher(int a,int ne,char *n,char *ad,char *s,char *t):Base(a,ne,n,ad,s)
{
title=new char[strlen(t)+1];
strcpy(titl