MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / main

Function main

Exercises/Modules/Chapter 10/Soln10_05.cpp:13–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

largerFunction · 0.70

Tested by

no test coverage detected