... not explicitly used the inline keyword. Today’s optimizing compilers are so sophisticated that it’s best to leave inlining decisions to the compiler.

Figure 6.16 uses inline function cube (lines 9–11) to calculate the volume of a cube. Keyword const in function cube’s parameter list (line 9) tells the compiler that the function does not modify variable side. This ensures that side’s value is not changed by the function during the calculation. (Keyword const is discussed in additional detail in Chapters 79.)

Software Engineering Observation 6.8

The const qualifier should be used to enforce the principle of least privilege. Using this principle to ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.