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

Function main

Examples/NoModules/Chapter 10/Ex10_02.cpp:10–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8template <typename T> const T* larger(const std::vector<T>& data);
9
10int main()
11{
12 int big_int {17011983}, small_int {10};
13 std::cout << std::format("Larger of {} and {} is {}",
14 big_int, small_int, larger(big_int, small_int)) << std::endl;
15 std::cout << std::format("Larger of {} and {} is {}",
16 big_int, small_int, *larger(&big_int, &small_int)) << std::endl;
17
18 std::vector<double> data {-1.4, 7.3, -100.0, 54.1, 16.3};
19 std::cout << "The largest value in data is " << *larger(data) << std::endl;
20
21 std::vector<std::string> words {"The", "higher", "the", "fewer"};
22 std::cout << std::format(R"(The largest word in words is "{}")", *larger(words))
23 << std::endl;
24}
25
26// Template for functions to return the larger of two values
27template <typename T>

Callers

nothing calls this directly

Calls 1

largerFunction · 0.70

Tested by

no test coverage detected