C++ Programming Ch.10 Exercise 7 Solution
Problem: λ€μ νλ‘κ·Έλ¨μ μ»΄νμΌ μ€λ₯κ° λ°μνλ€. μμ€μ μ΄λμμ μ μ»΄νμΌ μ€λ₯κ° λ°μνλκ°? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #include using namespace std; class Circle { int radius; public: Circle(int radius = 1) { this->radius = radius; } int getRadius() { return radius; } }; template T bigger(T a, T b) { // λ κ°μ λ§€κ° λ³μλ₯Ό λΉκ΅νμ¬ ν° κ°μ λ¦¬ν΄ if (a > b) return a; else return b; } int main() { int a = 20, b = 50, c; c = bigger(a, b); cout << "20κ³Ό 50μ€ ν° κ°μ " << c << endl; Circle waffle(10), pizza(20), y; y = bigger(waffle, pizza); cout << "waffleκ³Ό pizza μ€ ν° κ²μ λ°μ§λ¦μ " << y.getRadius() << endl; } Execution Result: ...