| 4 | import carton; // For the Carton class |
| 5 | |
| 6 | int main() |
| 7 | { |
| 8 | // Create a Box object and two Carton objects |
| 9 | Box box {40.0, 30.0, 20.0}; |
| 10 | Carton carton; |
| 11 | Carton chocolateCarton {"Solid bleached board"}; // Good old SBB |
| 12 | // Check them out - sizes first of all |
| 13 | std::cout << "box occupies " << sizeof box << " bytes" << std::endl; |
| 14 | std::cout << "carton occupies " << sizeof carton << " bytes" << std::endl; |
| 15 | std::cout << "candyCarton occupies " << sizeof chocolateCarton << " bytes" << std::endl; |
| 16 | |
| 17 | // Now volumes... |
| 18 | std::cout << "box volume is " << box.volume() << std::endl; |
| 19 | std::cout << "carton volume is " << carton.volume() << std::endl; |
| 20 | std::cout << "chocolateCarton volume is " << chocolateCarton.volume() << std::endl; |
| 21 | |
| 22 | std::cout << "chocolateCarton length is " << chocolateCarton.getLength() << std::endl; |
| 23 | |
| 24 | // Uncomment any of the following for an error... |
| 25 | // box.m_length = 10.0; |
| 26 | // chocolateCarton.m_length = 10.0; |
| 27 | } |