项目0 - 是春哥啊

来源:互联网 发布:游戏编程需要数学吗 编辑:程序博客网 时间:2024/06/11 18:52

问题及代码:

/*copyright(c)2016.烟台大学计算机学院 * All rights reserved, * 文件名称:text.Cpp * 作者:李一波 * 完成日期:2016年5月16日 * 版本号:vc++6.0 * * 问题描述:  请在下面程序的横线处填上适当内容,以使程序完整,并使程序的输出为:Name: 春哥 * 输入描述: * 程序输出: */#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;}

运行结果:

0 0
原创粉丝点击