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

Function main

Exercises/Modules/Chapter 12/Soln12_01/Soln12_01.cpp:5–28  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import <iostream>;
4
5int main()
6{
7 std::cout << "Create i with the value 10." << std::endl;
8 Integer i {10};
9 i.show();
10 std::cout << "Change value of i to 15." << std::endl;
11// i.m_value = 15; // Cannot assign directly to m_value
12 i.setValue(15);
13 i.show();
14
15 std::cout << "Create j with a value that is 150 times that of i." << std::endl;
16 const Integer j {150 * i.getValue()};
17 j.show();
18 std::cout << "Set value of j to ." << std::endl;
19// j.setValue(5000); // Cannot call setValue() on const object
20 // (show() and getValue() work, though)
21
22 std::cout << "Create k with the value 789." << std::endl;
23 Integer k {789};
24 k.show();
25 std::cout << "Set value of k to sum of i and j values." << std::endl;
26 k.setValue(i.getValue() + j.getValue());
27 k.show();
28}

Callers

nothing calls this directly

Calls 3

showMethod · 0.45
setValueMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected