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

Function main

Examples/NoModules/Chapter 12/Ex12_04/Ex12_04.cpp:24–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22bool Cube::hasLargerVolumeThan(Cube cube) { return volume() > cube.volume(); }
23
24int main()
25{
26 Cube box1{ 7.0 };
27 Cube box2{ 3.0 };
28 if (box1.hasLargerVolumeThan(box2))
29 std::cout << "box1 is larger than box2." << std::endl;
30 else
31 std::cout << "Volume of box1 is less than or equal to that of box2." << std::endl;
32
33 std::cout << "Volume of box1 is " << box1.volume() << std::endl;
34 if (box1.hasLargerVolumeThan(50.0))
35 std::cout << "Volume of box1 is greater than 50" << std::endl;
36 else
37 std::cout << "Volume of box1 is less than or equal to 50" << std::endl;
38}

Callers

nothing calls this directly

Calls 2

hasLargerVolumeThanMethod · 0.45
volumeMethod · 0.45

Tested by

no test coverage detected