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

Function main

Examples/NoModules/Chapter 20/Ex20_03/Ex20_03.cpp:7–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5void printSet(const std::set<int>& my_set); // Print the contents of a set to std::cout
6
7int main()
8{
9 std::set<int> my_set;
10
11 // Insert elements 1 through 4 in arbitrary order:
12 my_set.insert(1);
13 my_set.insert(4);
14 my_set.insert(3);
15 my_set.insert(3); // Elements 3 and 1 are added twice
16 my_set.insert(1);
17 my_set.insert(2);
18
19 printSet(my_set);
20
21 std::cout << "The element 1 occurs " << my_set.count(1) << " time(s)" << std::endl;
22
23 my_set.erase(1); // Remove the element 1 once
24 printSet(my_set);
25
26 my_set.clear(); // Remove all elements
27 printSet(my_set);
28}
29
30void printSet(const std::set<int>& my_set)
31{

Callers

nothing calls this directly

Calls 2

printSetFunction · 0.70
clearMethod · 0.45

Tested by

no test coverage detected