#include <iostream>
using namespace std;
class Point {
public:
int x, y;
public:
//생성자함수: 클래스를 객체화시킬때 값을 초기화 시키는 기능
//생성자 함수는 반드시 클래스명하고 같아야 한다
//함수를 오버로딩 시켜서 여러개의 인수 형태를 지정해서 초기화 가능
Point();
void moveLeft(); //좌표 왼쪽으로 이동시키는 함수
void moveRight(); //좌표 오른쪽으로 이동시키는 함수
void print(); //좌표 출력하는 함수
};
class childPoint : public Point
{
public:
void moveUp();
void moveDown();
};
//생성자 함수 구현
//객체 생성시 x좌표 50 y좌표 50
Point::Point() {
x = 50;
y = 50;
print();
}
//왼쪽으로 이동하는 함수
void Point::moveLeft() {
x = x - 1;
print();
}
//오른쪽으로 이동하는 함수
void Point::moveRight() {
y = y - 1;
print();
}
void Point::print()
{
cout << x << " " << y << endl;
}
void childPoint::moveUp() {
x = x + 10;
print();
}
void childPoint::moveDown() {
y = y - 10;
print();
}
int main() {
Point p;
childPoint cp;
cout << "------------------" << endl;
p.moveLeft();
p.moveLeft();
cout << "------------------" << endl;
p.moveRight();
p.moveRight();
cout << "------------------" << endl;
cp.moveUp();
cp.moveUp();
cout << "------------------" << endl;
cp.moveDown();
cp.moveDown();
return 0;
}