October 2004
Intermediate to advanced
240 pages
6h 22m
English
const proactivelyconst is your friend: Immutable values are easier to understand, track, and reason about, so prefer constants over variables wherever it is sensible and make const your default choice when you define a value: It’s safe, it’s checked at compile time (see Item 14), and it’s integrated with C++’s type system. Don’t cast away const except to call a const-incorrect function (see Item 94).
Constants simplify code because you only have to look at where the constant is defined to know its value everywhere. Consider this code:

When seeing len’s definition above, you gain instant confidence about len’s semantics ...