码迷,mamicode.com
首页 > 其他好文 > 详细

【项目0 - 是春哥啊】

时间:2015-05-13 10:25:43      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:namespace   c++   经验   技术   计算机科学   

【项目0 - 是春哥啊】
请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:
Name: 春哥
Grade: 19


 

#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: ___________//(1)
{
public:
    Student(char* s, int g):__________ // (2)
    {grade=g;}
    void display1( ) {
        _________;   //  (3)
        cout<<"Grade: "<<grade<<endl;
    }
private:
    int grade;
};
int main( )
{
    Student s("春哥",19);
    ___________;       //  (4)
    return 0;
}


 

 

 

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

技术分享

【项目0 - 是春哥啊】

标签:namespace   c++   经验   技术   计算机科学   

原文地址:http://blog.csdn.net/i__am__legend/article/details/45688373

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!