16.2

来源:互联网 发布:python 3 try except 编辑:程序博客网 时间:2024/06/08 15:34
/* C++ДњТы */#include <iostream>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;};/* C++ДњТы */class Student1:private Student{   public:   void get_value1()    {        Student::get_value();        cin>>age>>addr;    }    void display1( )    {       Student::display();       cout<<"age: "<<age<<endl;       cout<<"address: "<<addr<<endl;    }   private:   int age;   string addr;};int main(){    Student1 stud1;    stud1.get_value1();    stud1.display1();    return 0;}

0 0