1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <string>
using namespace std;
 
class Point {
    int x, y;
public:
    Point(int x, int y) { this->= x; this->= y; }
    int getX() { return x;}
    int getY() { return y;}
protected:
    void move(int x, int y) { this->= x; this->= y; }
};
 
class ColorPoint:public Point {
    string color;
public:
    ColorPoint(int x, int y, string color) :Point(x, y) { this->color = color; }
    void setPoint(int x, int y) { move(x, y); }
    void setColor(string color) { this->color = color; }
    void show() { cout << color << "색으로 (" << getX() << ", " << getY() << ")에 위치한 점입니다.\n"; }
};
 
int main() {
    ColorPoint cp(55"RED");
    cp.setPoint(1020);
    cp.setColor("BLUE");
    cp.show();
}
cs


+ Recent posts