OJ 2445 입 출력 공유 상속

/*
* Copyright (c)2013,            
* All rightsreserved.
*     : array.cpp
*       :      
*     :2014   6   10   
*    : v1.0
*     : 
*/
#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;

    char name[10];

    char sex;

};



//        ,        ,          

/* C++   */
class Student1:public Student
{
    public:
    void get_value_1()
    {
        cin>>age>>addr;
    }
    void display_1()
    {
        cout<<"age: "<<age<<endl;
        cout<<"address: "<<addr<<endl;
    }
    private:
    int age;
    string addr;
};



int  main()

{

    Student1 stud1;

    stud1.get_value();

    stud1.get_value_1();

    stud1.display();

    stud1.display_1();

    return 0;

}






좋은 웹페이지 즐겨찾기