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

Method printVolume

Examples/NoModules/Chapter 12/Ex12_11/Box.cpp:18–23  ·  view source on GitHub ↗

Modify mutable member variable from a const member function

Source from the content-addressed store, hash-verified

16
17// Modify mutable member variable from a const member function
18void Box::printVolume() const
19{
20 // Count how many times printVolume() is called using a mutable member in a const function
21 std::cout << "The volume of this box is " << volume() << std::endl;
22 std::cout << "printVolume() has been called " << ++m_count << " time(s)" << std::endl;
23}

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected