1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
 
class Oval {
    int width;
    int height;
public:
    Oval() { width = 1; height = 1; }
    Oval(int width, int height) { this->width = width; this->height = height; }
    ~Oval() { cout << "Oval 소멸 : width = " << width << ", height = " << height << endl; }
    void set(int width, int height) { this->width = width; this->height = height; }
    int getWidth() { return width; }
    int getHeight() { return height; }
    void show() { cout << "width = " << width << ", height = " << height << endl; }
};
 
int main() {
    Oval a, b(34);
    a.set(1020);
    a.show();
    cout << b.getWidth() << "," << b.getHeight() << endl;
}
cs


+ Recent posts