| 3 | import boxes; |
| 4 | |
| 5 | int main() |
| 6 | { |
| 7 | // Box box{20.0, 30.0, 40.0}; // Uncomment for compiler error |
| 8 | |
| 9 | ToughPack hardcase {20.0, 30.0, 40.0}; // A derived box - same size |
| 10 | Carton carton {20.0, 30.0, 40.0, "plastic"}; // A different derived box |
| 11 | |
| 12 | Box*pBox {&hardcase}; // Base pointer - derived address |
| 13 | std::cout << "hardcase volume is " << pBox->volume() << std::endl; |
| 14 | |
| 15 | pBox = &carton; // New derived address |
| 16 | std::cout << "carton volume is " << pBox->volume() << std::endl; |
| 17 | } |