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 Circle { int radius; public: Circle(int radius = 0) { this->radius = radius; } void show() { cout << "radius = " << radius << " 인 원" << '\n'; } friend Circle operator+(int x, Circle a); }; Circle operator+(int x, Circle a) { a.radius += x; return a; } int main() { Circle a(5), b(4); b = 1 + a; a.show(); b.show(); } | cs |
'Programming > 명품 C++ Programming' 카테고리의 다른 글
| 명품 C++ Programming 실습문제 7장 10번 (0) | 2018.06.18 |
|---|---|
| 명품 C++ Programming 실습문제 7장 9번 (0) | 2018.06.18 |
| 명품 C++ Programming 실습문제 7장 7번 (0) | 2018.06.18 |
| 명품 C++ Programming 실습문제 7장 6번 (0) | 2018.06.18 |
| 명품 C++ Programming 실습문제 7장 5번 (0) | 2018.06.17 |