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

Method volume

Examples/NoModules/Chapter 15/Ex15_10/Carton.h:17–21  ·  view source on GitHub ↗

Function to calculate the volume of a Carton object

Source from the content-addressed store, hash-verified

15
16 // Function to calculate the volume of a Carton object
17 double volume() const override
18 {
19 const double volume {(m_length - 0.5) * (m_width - 0.5) * (m_height - 0.5)};
20 return std::max(volume, 0.0); // Or: return volume > 0.0 ? volume : 0.0;
21 }
22private:
23 std::string m_material;
24};

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected