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

Method printVolume

Examples/Modules/Chapter 12/Ex12_11/Box.cpp:19–24  ·  view source on GitHub ↗

Modify mutable member variable from a const member function

Source from the content-addressed store, hash-verified

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

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected