Inheritance / function Overloading /
** 주의 : 관련없는 클래스끼리 함부로 상속하는 건 객체 지향이라고 할 수 없음
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;
}
};