| 2 | #define BOX_H |
| 3 | |
| 4 | class Box |
| 5 | { |
| 6 | public: |
| 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 | { |
| 20 | return volume() < aBox.volume(); |
| 21 | } |
| 22 | |
| 23 | bool operator<(double value) const; // Compare Box volume < double value |
| 24 | |
| 25 | private: |
| 26 | double m_length{ 1.0 }; |
| 27 | double m_width{ 1.0 }; |
| 28 | double m_height{ 1.0 }; |
| 29 | }; |
| 30 | |
| 31 | // Compare the volume of a Box object with a constant |
| 32 | inline bool Box::operator<(double value) const |
nothing calls this directly
no outgoing calls
no test coverage detected