求帮我看下做到一半卡主了先定义一个person类,包含数据成员,性别,姓名,以该类为基类,派生出学生类。在学生类中增加数据成员学号、成绩。创建三个学生,并输入每
#include <iostream>using namespace std;
class person{
public:
person(){
name="卡卡";
sex="男";
}
private:
string name;
string sex;
};
class student:public person{
public:
student(string a,string j,string x,string c){
name=a;
sex=j;
num=x;
chengji=c;
}
void output(){
cout<<"姓名:"<<name<<" "<<"性别:"<<sex<<" "<<"学号:"<<num<<"成绩:"<<chengji<<endl;
}
private:
string name;
string sex;
string num;
string chengji;
};
int main(){
student s1;
s1.output;
student s2("梅西","男","20180102","90");
s2.output;
return 0;
}