| 6 | template<typename T> T larger(T a, T b); // Function template prototype |
| 7 | |
| 8 | int main() |
| 9 | { |
| 10 | std::cout << "Larger of 1.5 and 2.5 is " << larger(1.5, 2.5) << std::endl; |
| 11 | std::cout << "Larger of 3.5 and 4.5 is " << larger(3.5, 4.5) << std::endl; |
| 12 | |
| 13 | int big_int {17011983}, small_int {10}; |
| 14 | std::cout << std::format("Larger of {} and {} is {}\n", |
| 15 | big_int, small_int, larger(big_int, small_int)); |
| 16 | |
| 17 | std::string a_string {"A"}, z_string {"Z"}; |
| 18 | std::cout << std::format(R"(Larger of "{}" and "{}" is "{}")", |
| 19 | a_string, z_string, larger(a_string, z_string)) << std::endl; |
| 20 | } |
| 21 | |
| 22 | // Template for functions to return the larger of two values |
| 23 | template <typename T> |