| 33 | |
| 34 | |
| 35 | int main() |
| 36 | { |
| 37 | Box box1{ 2.0, 3.0, 4.0 }; // An arbitrary box |
| 38 | Box box2{ 5.0 }; // A box that is a cube |
| 39 | std::cout << "box1 volume = " << box1.volume() << std::endl; |
| 40 | std::cout << "box2 volume = " << box2.volume() << std::endl; |
| 41 | |
| 42 | Box box3{ box2 }; |
| 43 | std::cout << "box3 volume = " << box3.volume() << std::endl; // Volume = 125 |
| 44 | } |
| 45 | |
| 46 | // A constructor that initializes all three member variables |
| 47 | Box::Box(double length, double width, double height) |