| 5 | #include <format> |
| 6 | |
| 7 | class Box |
| 8 | { |
| 9 | public: |
| 10 | Box() = default; |
| 11 | Box(double length, double width, double height) |
| 12 | : m_length{length}, m_width{width}, m_height{height} {}; |
| 13 | |
| 14 | double volume() const |
| 15 | { |
| 16 | return m_length * m_width * m_height; |
| 17 | } |
| 18 | |
| 19 | int compare(const Box& box) const |
| 20 | { |
| 21 | if (volume() < box.volume()) return -1; |
| 22 | if (volume() == box.volume()) return 0; |
| 23 | return +1; |
| 24 | } |
| 25 | |
| 26 | friend std::ostream& operator<<(std::ostream& out, const Box& box) |
| 27 | { |
| 28 | return out << std::format("Box({:.1f},{:.1f},{:.1f})", box.m_length, box.m_width, box.m_height); |
| 29 | } |
| 30 | |
| 31 | private: |
| 32 | double m_length {1.0}; |
| 33 | double m_width {1.0}; |
| 34 | double m_height {1.0}; |
| 35 | }; |
| 36 | |
| 37 | #endif |
nothing calls this directly
no outgoing calls
no test coverage detected