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(3, 4); a.set(10, 20); a.show(); cout << b.getWidth() << "," << b.getHeight() << endl; } | cs |
'Programming > 명품 C++ Programming' 카테고리의 다른 글
| 명품 C++ Programming 실습문제 3장 8-(2)번 (0) | 2018.04.28 |
|---|---|
| 명품 C++ Programming 실습문제 3장 8-(1)번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 6번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 5번 (0) | 2018.04.28 |
| 명품 C++ Programming 실습문제 3장 4번 (0) | 2018.04.28 |