oj4

来源:互联网 发布:怎么做个快3软件 编辑:程序博客网 时间:2024/05/17 20:23
#include <iostream>#include <string>using namespace std;class Student{public:    void get_value()    {        cin>>num>>name>>sex;    }    void display( )    {        cout<<"num: "<<num<<endl;        cout<<"name: "<<name<<endl;        cout<<"sex: "<<sex<<endl;    }private :    int num;    string name;    char sex;};class Student1:private Student {   public :      void get_value_1()    {        get_value();        cin>>age>>addr;    }   void display_1( )    {        display();        cout<<"age: "<<age<<endl;        cout<<"address: "<<addr<<endl;            }      private:   string addr;   int age;    };/* C++代码 */int main(){    Student1 stud1;    stud1.get_value1();    stud1.display1();    return 0;}

0 0