/*
    CRerference1.cpp
*/

#include <iostream>

using std::cout;
using std::endl;

class Person
{
public :
    void Sleep() const
    {
        cout<<"Sleep"<<endl;
    }
};

class Student : public Person
{
public :
    void Study() const
    {
        cout<<"Study"<<endl;
    }
};

class PartTimeStd : public Student
{
public :
    void Work() const
    {
        cout<<"Work"<<endl;
    }
};

int main(void)
{
    PartTimeStd p;
    Student& ref1 = p;
    Person&  ref2 = p;

    p.Sleep();
    ref1.Sleep();
    ref2.Sleep();

    return 0;
}

 

반응형

'C, C++, Java' 카테고리의 다른 글

Overriding1.cpp  (0) 2014.05.02
CReference2.cpp  (0) 2014.05.02
CPointer2.cpp  (0) 2014.05.02
EmployeeManager3.cpp  (0) 2014.05.02
Person.cpp  (0) 2014.04.30

+ Recent posts