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

Function main

Examples/Modules/Chapter 14/Ex14_01/Ex14_01.cpp:6–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4import carton; // For the Carton class
5
6int 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}

Callers

nothing calls this directly

Calls 2

volumeMethod · 0.45
getLengthMethod · 0.45

Tested by

no test coverage detected