Class to represent a box
| 3 | |
| 4 | // Class to represent a box |
| 5 | class Box |
| 6 | { |
| 7 | public: |
| 8 | // Box() {} // Explicitly defined default constructor |
| 9 | Box() = default; // Defaulted default constructor |
| 10 | |
| 11 | // Constructor |
| 12 | Box(double length, double width, double height) |
| 13 | { |
| 14 | std::cout << "Box constructor called." << std::endl; |
| 15 | m_length = length; |
| 16 | m_width = width; |
| 17 | m_height = height; |
| 18 | } |
| 19 | |
| 20 | // Function to calculate the volume of a box |
| 21 | double volume() |
| 22 | { |
| 23 | return m_length * m_width * m_height; |
| 24 | } |
| 25 | |
| 26 | private: |
| 27 | double m_length {1.0}; |
| 28 | double m_width {1.0}; |
| 29 | double m_height {1.0}; |
| 30 | }; |
| 31 | |
| 32 | int main() |
| 33 | { |
nothing calls this directly
no outgoing calls
no test coverage detected