【项目1 - 龙三】
请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:Name: 龙三
Grade: 19
#include <iostream>
#include <string>
using namespace std;
class Person{
public:
Person(string s){
name=s;
}
void display( ){
cout<<"Name: "<<name<<endl;
}
private:
string name;
};
class Student:public Person//(1)参考教材P169加底纹部分
{
public:
Student(string s, int g):Person(s) // (2)
{grade=g;}
void display1( ) {
display(); // (3)
cout<<"Grade: "<<grade<<endl;
}
private:
int grade;
};
int main( )
{
Student s("龙三",19);
s.display1(); // (4)
return 0;
}