| 3 | import cereal; // For the CerealPack class |
| 4 | |
| 5 | int main() |
| 6 | { |
| 7 | CerealPack cornflakes{ 8.0, 3.0, 10.0, "Cornflakes" }; |
| 8 | |
| 9 | std::cout << "cornflakes volume is " << static_cast<Carton&>(cornflakes).volume() |
| 10 | << std::endl |
| 11 | << "cornflakes weight is " << static_cast<FoodContainer&>(cornflakes).getWeight() |
| 12 | << std::endl; |
| 13 | /* |
| 14 | // Alternate solution by explicitly qualifying the base class name (see also Ex14_07) |
| 15 | std::cout << "cornflakes volume is " << cornflakes.Carton::volume() << std::endl |
| 16 | << "cornflakes weight is " << cornflakes.FoodContainer::getWeight() |
| 17 | << std::endl; |
| 18 | */ |
| 19 | } |