| 5 | #include <ostream> // For std::ostream |
| 6 | |
| 7 | class Box |
| 8 | { |
| 9 | public: |
| 10 | Box() = default; // Default constructor |
| 11 | Box(double length, double width, double height) |
| 12 | : m_length{ std::max(length,width) } |
| 13 | , m_width { std::min(length,width) } |
| 14 | , m_height{ height } |
| 15 | {} |
| 16 | |
| 17 | double volume() const; // Function to calculate the volume |
| 18 | |
| 19 | // Accessors |
| 20 | double getLength() const { return m_length; } |
| 21 | double getWidth() const { return m_width; } |
| 22 | double getHeight() const { return m_height; } |
| 23 | |
| 24 | // Functions that add full support for comparison operators |
| 25 | std::partial_ordering operator<=>(const Box& aBox) const; |
| 26 | std::partial_ordering operator<=>(double value) const; |
| 27 | bool operator==(const Box& aBox) const = default; |
| 28 | |
| 29 | Box& operator+=(const Box& aBox); // Function to add a Box objects |
| 30 | Box operator+(const Box& aBox) const; // Function to add two Box objects |
| 31 | |
| 32 | private: |
| 33 | double m_length {1.0}; |
| 34 | double m_width {1.0}; |
| 35 | double m_height {1.0}; |
| 36 | }; |
| 37 | |
| 38 | std::ostream& operator<<(std::ostream& stream, const Box& box); |
| 39 |
nothing calls this directly
no outgoing calls
no test coverage detected