yh_secret 2023-02-20 18:37 采纳率: 50%
浏览 36
已结题

c++在线请教,为什么会出现这个问题??求解答!

c++在线请教,为什么会出现这个问题??求解答!

#include<iostream>
#include<string>
using namespace std;

class Person
{
public:
    Person(string nam, char s, int a)
    {
        name = nam; sex = s; age = a;
    }
protected:
    string name;
    char sex;
    int age;
};
class teacher :virtual Person
{
public:
    teacher(string nam,char s,int a,string t):Person(nam,s,a)
    {
        title = t;
    }
protected:
    string title;
};
class student :virtual public Person
{
public:
    student(string nam, char s, int a, float sco) :Person(nam, s, a)
    {
        score = sco;
    }
protected:
    float score;
};
class graduate :public teacher, public student
{
public:
    graduate(string nam, char s, int a, string t, float sco, float w) :Person(nam, s, a), teacher(nam, s, a, t), student(nam, s, a, sco)
    {
        wage = w;
    }
    void show()
    {
        cout << "name:" << name << endl;
        cout << "sex:" << sex << endl;
        cout << "age:" << age << endl;
        cout << "title:" << title << endl;
        cout << "score:" << score << endl;
        cout << "wage:" << wage << endl;
    }
private:
    float wage;
};
int main()
{
    graduate grad1("WANG_LI","f", 24, "assistant", 89.5, 1200);
    grad1.show();
    return 0;
}

img

  • 写回答

4条回答 默认 最新

  • Huazie 全栈领域优质创作者 2023-02-20 18:42
    关注

    你的 第二个参数是 char 类型,改成如下:

    graduate grad1("WANG_LI",'f', 24, "assistant", 89.5, 1200);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 3月9日
  • 已采纳回答 3月1日
  • 创建了问题 2月20日

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler