| 22 | const char* larger(const char* a, const char* b); |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | std::cout << "Larger of 1.5 and 2.5 is " << larger(1.5, 2.5) << std::endl; |
| 27 | std::cout << "Larger of 3.5 and 4.5 is " << larger(3.5, 4.5) << std::endl; |
| 28 | |
| 29 | const int big_int {17011983}, small_int {10}; |
| 30 | std::cout << "Larger of " << big_int << " and " << small_int << " is " |
| 31 | << larger(big_int, small_int) << std::endl; |
| 32 | |
| 33 | const auto a_string {"A"}, z_string {"Z"}; // now string literals (type const char[])! |
| 34 | std::cout << "Larger of \"" << a_string << "\" and \"" << z_string << "\" is " |
| 35 | << '"' << larger(a_string, z_string) << '"' << std::endl; |
| 36 | } |
| 37 | |
| 38 | // Template for functions to return the larger of two values |
| 39 | template <typename T> |