MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / main

Function main

Examples/Modules/Chapter 14/Ex14_07A/Ex14_07A.cpp:5–19  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3import cereal; // For the CerealPack class
4
5int 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}

Callers

nothing calls this directly

Calls 2

volumeMethod · 0.45
getWeightMethod · 0.45

Tested by

no test coverage detected