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

Class Box

Examples/NoModules/Chapter 15/Ex15_08/Box.h:5–29  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <iostream>
4
5class Box
6{
7public:
8 Box(double length, double width, double height)
9 : m_length {length}, m_width {width}, m_height {height}
10 {
11 std::cout << "Box constructor called for a Box of volume " << volume() << std::endl;
12 }
13 virtual ~Box()
14 {
15 std::cout << "Box destructor called for a Box of volume " << volume() << std::endl;
16 }
17
18 // Function to calculate volume of a Box
19 virtual double volume() const { return m_length * m_width * m_height; }
20
21 void showVolume() const
22 {
23 std::cout << "The volume from inside Box::showVolume() is "
24 << volume() << std::endl;
25 }
26
27private:
28 double m_length, m_width, m_height;
29};
30
31#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected