#include <iostream>
#include <cstring>
using namespace std;
class Person
{
public:
Person(char* s)
{
strcpy(name,s);
}
void display( )
{
cout<<"Name: "<<name<<endl;
}
private:
char name [20];
};
class Student: public Person
{
public:
Student(char* s, int g):Person(s)
{
grade=g;
}
void display1( )
{
display();
cout<<"Grade: "<<grade<<endl;
}
private:
int grade;
};
int main( )
{
Student s("春哥",19);
s.display1();
return 0;
}
运行结果: