钱来no.1 2021-05-28 23:19 采纳率: 0%
浏览 193

没有与参数列表匹配的构造函数

#include<iostream>

#include<string>

using namespace std;

class Person//定义一个基类

{

protected:

    string name;

    int age;

    char sex;

    string address;

    long telephone;

public:

    Person(const string a, int b, char s, const string add, long tel);

};

Person::Person(const string a, int b, char s, const string add, long tel) :name(a), age(b), sex(s), address(add), telephone(tel) {}

class Teacher :virtual public Person//教师类

{

public:

    string title;//职称

    Teacher(const string a, int b, char s, const string add, long tel, const string tit);

    void display();

};

Teacher::Teacher(const string a, int b, char s, const string add, long tel, const string tit) :Person(a, b, s, add, tel), title(tit) {}

void Teacher::display()

{

    cout << "姓名为:" << name << endl;

    cout << "年龄为:" << age << endl;

    cout << "性别为:" << sex << endl;

    cout << "地址为:" << address << endl;

    cout << "电话为:" << telephone << endl;

    cout << "职称为:" << title << endl;

}

class Cadre :virtual public Person//干部类

{

public:

    string post;//职务

    Cadre(const string a, int b, char s,const string add,const long tel, string post);

    void display();

};

Cadre::Cadre(const string a, int b, char s, const string add, long tel, const string post) :Person(a, b, s, add, tel), post(post) {}

void Cadre::display()

{

    cout << "姓名为:" << name << endl;

    cout << "年龄为:" << age << endl;

    cout << "性别为:" << sex << endl;

    cout << "地址为:" << address << endl;

    cout << "电话为:" << telephone << endl;

    cout << "职务为:" << post << endl;

}

class Teacher_Cadre :public Teacher, public Cadre//教师兼干部类

{

public:

    int wages;//工资

    Teacher_Cadre(const string a, int b, char s, const string add, long tel, const string tit, const string post, int w);

    void show();

};

Teacher_Cadre::Teacher_Cadre(const string a, int b, char s, const string add, long tel, const string tit, const string post, int w) :Person(a, b, s, add, tel), Teacher(a, b, s, add, tel, tit), Cadre(a, b, s, add, tel, post), wages(w) {}

void Teacher_Cadre::show()

{

    Teacher::display();

    cout << "工资为:" << wages << endl;

}

int main()

{

    Teacher_Cadre m("李华", 36, "男", "湖北大学教工处", 123456, "英语老师", "教导主任", 6000);

    m.show();

    system("pause");

    return 0;

}

代码如上

  • 写回答

2条回答 默认 最新

  • CSDN专家-link 2021-05-29 04:36
    关注

    构造函数第三个参数是char s,你传递的是"男“,不匹配。"男”是中文,占两个字节,你需要把性别也定义成字符数组才行

    评论

报告相同问题?

悬赏问题

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