#include <iostream>
#include <string>
using namespace std;
//定义一个基类Person,Person里有5个protected类型的成员
class Person
{
public:
Person(string , int, char, string, string);
void display();
protected:
//姓名
string name;
//年龄
int age;
//性别
char sex;
//地址
string addr;
//电话
string tel;
};
Person::Person(string nam, int a, char s, string ad, string te)
{
name = nam; age = a; sex = s; addr = ad; tel = te;
}
void Person::display()
{
cout << "name: " << name << endl;
cout << "age: " << age << endl;
cout << "sex: " << sex << endl;
cout << "address: " << addr << endl;
cout << "tel: " << tel << endl;
}
class Teacher:virtual public Person
{
public:
Teacher(string nam, int a, char s, string ad, string te, string tit) :Person(nam, a, s, ad, te),title(tit){}
void display1();
protected:
string title;
};
void Teacher::display1()
{
cout << "name: " << name << endl;
cout << "age: " << age << endl;
cout << "sex: " << sex << endl;
cout << "title: " << title << endl;
cout << "address: " << addr << endl;
cout << "tel: " << tel << endl;
}
class Cadre:virtual public Person
{
public:
Cadre(string nam, int a, char s, string ad, string te, string po) :Person(nam, a, s, ad, te),post(po){}
void display2();
protected:
string post;
};
void Cadre::display2()
{
cout << "name: " << name << endl;
cout << "age: " << age << endl;
cout << "sex: " << sex << endl;
cout << "address: " << addr << endl;
cout << "tel: " << tel << endl;
cout << "post: " << post << endl;
}
class Teacher_Cadre : public Teacher, public Cadre
{
public:
Teacher_Cadre(string nam, int a, char s, string ad, string te, string tit, string po, double w) :
Teacher(nam, a, s, ad, te, tit), Cadre(nam, a, s, ad, te, po),wages(w){}
void show();
private:
double wages;
};
void Teacher_Cadre::show()
{
Teacher::display();
cout << "post: " << Cadre::post << endl;
cout << "wages: " << wages << endl;
};
int main()
{
Teacher_Cadre person("YuDunhui", 18, 'M', "Wuhan", 88664102, "professor", "assitant", 20000);
person.show();
return 0;
}
不知道哪里错了,求大家解答编译问题
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
7条回答 默认 最新
悬赏问题
- ¥15 有偿求苍穹外卖环境配置
- ¥15 代码在keil5里变成了这样怎么办啊,文件图像也变了,
- ¥20 Ue4.26打包win64bit报错,如何解决?(语言-c++)
- ¥15 clousx6整点报时指令怎么写
- ¥30 远程帮我安装软件及库文件
- ¥15 关于#自动化#的问题:如何通过电脑控制多相机同步拍照或摄影(相机或者摄影模组数量大于60),并将所有采集的照片或视频以一定编码规则存放至规定电脑文件夹内
- ¥20 深信服vpn-2050这台设备如何配置才能成功联网?
- ¥15 Arduino的wifi连接,如何关闭低功耗模式?
- ¥15 Android studio 无法定位adb是什么问题?
- ¥15 C#连接不上服务器,