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

Function main

Examples/Modules/Chapter 10/Ex10_02.cpp:11–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9template <typename T> const T* larger(const std::vector<T>& data);
10
11int main()
12{
13 int big_int {17011983}, small_int {10};
14 std::cout << std::format("Larger of {} and {} is {}",
15 big_int, small_int, larger(big_int, small_int)) << std::endl;
16 std::cout << std::format("Larger of {} and {} is {}",
17 big_int, small_int, *larger(&big_int, &small_int)) << std::endl;
18
19 std::vector<double> data {-1.4, 7.3, -100.0, 54.1, 16.3};
20 std::cout << "The largest value in data is " << *larger(data) << std::endl;
21
22 std::vector<std::string> words {"The", "higher", "the", "fewer"};
23 std::cout << std::format(R"(The largest word in words is "{}")", *larger(words))
24 << 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