... "\n\nThe volume of a box with length 10,\n"
24         << "width 5 and height 2 is: " << boxVolume(10, 5, 2)
25         << endl;
26   }
27
28   // function boxVolume calculates the volume of a box
29   unsigned int boxVolume(unsigned int length, unsigned int width,
30      unsigned int height) {
31      return length * width * height;
32   }

The default box volume is: 1

The volume of a box with length 10,
width 1 and height 1 is: 10

The volume of a box with length 10,
width 5 and height 1 is: 50

The volume of a box with length 10,
width 5 and height 2 is: 100

The first call to boxVolume (line 12) specifies no arguments, thus using all three default values of 1. The second call (line 16) passes only a length argument, thus using default values of 1 for the width and height

Get C++ How to Program, 10/e now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.