Inheritance / function Overloading /

1.Inheritance(상속)

1-1.사용하는 이유와 목적

** 주의 : 관련없는 클래스끼리 함부로 상속하는 건 객체 지향이라고 할 수 없음

1-2. 사용법

class Point{
    int x, y;
public:
    Point():x(0), y(0){}
    void setPoint(int x, int y){
        this->x = x;
        this->y = y;
    }
    void print() const {
        cout << this->x << ", " << this->y << endl;
    }
};

class ColorPoint : public Point //Point클래스를 상속받음
{ 
    string color;
public:
    ColorPoint():color("white"){}
    void setColor(string color){
        this->color = color;
    }
    void printColor() const {
        cout << this->color << endl;
    }
};

1-3. 다중 상속(Multiple Inheritance)

1-4. 가상 상속(Virtual Inheritance)

Untitled