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

Function main

Exercises/Modules/Chapter 12/Soln12_05/Soln12_05.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16int main()
17{
18 std::cout << "Create i with the value 0." << std::endl;
19 Integer i;
20 i.show();
21
22 Integer::printCount(); // 1 object
23
24 if (i.getValue() == 0)
25 {
26 std::cout << "Create j from object i." << std::endl;
27 Integer j {i};
28 j.show();
29 Integer::printCount(); // 2 objects
30 }
31
32 Integer::printCount(); // 1 object again (Integer j was deleted because its scope ended)
33
34 Integer array[] { 1, 2, 3 };
35
36 Integer::printCount(); // 4 objects
37
38 showIntegerRef(array[0]);
39 showIntegerVal(array[1]);
40
41 Integer::printCount(); // 4 objects again
42}

Callers

nothing calls this directly

Calls 4

showIntegerRefFunction · 0.70
showIntegerValFunction · 0.70
showMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected