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

Class Box

Examples/NoModules/Chapter 12/Ex12_07/Box.h:4–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2#define BOX_H
3
4class Box
5{
6public:
7 // Constructors
8 Box() = default;
9 Box(double length, double width, double height);
10
11 double volume(); // Function to calculate the volume of a box
12
13 // Functions to provide access to the values of member variables
14 double getLength() { return m_length; }
15 double getWidth() { return m_width; }
16 double getHeight() { return m_height; }
17
18 // Functions to set member variable values
19 void setLength(double length) { if (length > 0) m_length = length; }
20 void setWidth(double width) { if (width > 0) m_width = width; }
21 void setHeight(double height) { if (height > 0) m_height = height; }
22
23private:
24 double m_length{1.0};
25 double m_width {1.0};
26 double m_height{1.0};
27};
28
29#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected