I t314 2021-06-12 21:40 采纳率: 0%
浏览 68
已结题

不知道哪里错了,求大家解答编译问题

#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;
}

  • 写回答

7条回答 默认 最新

  • 关注

    有错误信息吗?把编译报错的信息发出来看看。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月8日

悬赏问题

  • ¥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#连接不上服务器,