继承类求助
  • 板块学术版
  • 楼主打表出省一
  • 当前回复3
  • 已保存回复3
  • 发布时间2020/5/1 15:56
  • 上次更新2023/11/7 03:28:27
查看原帖
继承类求助
248784
打表出省一楼主2020/5/1 15:56
#include <bits/stdc++.h>
using namespace std;
class Person
{
public:
    void display()
    {
        cout << "name:" << name << endl;
        cout << "age:" << age << endl;
        cout << "sex:" << sex << endl;
        cout << endl;
    }
    Person(){
        name = "ozzy";
        age = 14;
        sex = 'M';
    }
private:
    string name;
    int age;
    char sex;
};
class Student : public Person
{
public:
    void display()
    {
        cout << "name:" << Person.name << endl;
        cout << "age:" << Person.age << endl;
        cout << "sex:" << Person.sex << endl;
        cout << "num:" << num << endl;
        cout << "class:" << Class << endl;
    }
    Student(){
        num = 181154;
        Class = 11;
    }
private:
    int num;
    int Class;
};
int main()
{
    Person a;
    a.display();
    return 0;
}

这个哪里错了啊?

2020/5/1 15:56
加载中...