您的位置:首页 > 其它

第十一周【补充项目1 - 是春哥啊】

2016-05-19 08:35 295 查看
#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//(1)
{
public:
Student(char* 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;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: