补充填空

#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;
}

运行结果:


发布了74 篇原创文章 · 获赞 9 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/fu_yunjian/article/details/52354097