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

Class Box

Examples/NoModules/Chapter 13/Ex13_01/Box.h:4–25  ·  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 l, double w, double h) : m_length{l}, m_width{w}, m_height{h} {}
10
11 double volume() const { return m_length * m_width * m_height; }
12
13 // Accessors
14 double getLength() const { return m_length; }
15 double getWidth() const { return m_width; }
16 double getHeight() const { return m_height; }
17
18 bool operator<(const Box& aBox) const // Less-than operator
19 { return volume() < aBox.volume(); }
20
21private:
22 double m_length {1.0};
23 double m_width {1.0};
24 double m_height {1.0};
25};
26
27#endif

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected