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

Function main

Examples/Modules/Chapter 09/Ex9_03A.cpp:20–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18std::string largest(std::span<const std::string> words);
19
20int main()
21{
22 const double array[] {1.5, 44.6, 13.7, 21.2, 6.7};
23 const std::vector numbers {15, 44, 13, 21, 6, 8, 5, 2};
24 const std::vector data{3.5, 5.0, 6.0, -1.2, 8.7, 6.4};
25 const std::array array_data{ 3.5, 5.0, 6.0, -1.2, 8.7, 6.4 }; // Throwing in an std::array for good measure
26 const std::vector<std::string> names {"Charles Dickens", "Emily Bronte",
27 "Jane Austen", "Henry James", "Arthur Miller"};
28 std::cout << "The largest of array is " << largest(array) << std::endl;
29 std::cout << "The largest of numbers is " << largest(numbers) << std::endl;
30 std::cout << "The largest of data is " << largest(data) << std::endl;
31 std::cout << "The largest of array_data is (also) " << largest(array_data) << std::endl;
32 std::cout << "The largest of names is " << largest(names) << std::endl;
33}
34
35// Finds the largest of a span of values
36double largest(std::span<const double> data)

Callers

nothing calls this directly

Calls 1

largestFunction · 0.70

Tested by

no test coverage detected