August 2012
Intermediate to advanced
976 pages
30h 17m
English
const Parameters and ArgumentsWhen we use parameters that are const, it is important to remember the discussion of top-level const from § 2.4.3 (p. 63). As we saw in that section, a top-level const is one that applies to the object itself:
const int ci = 42; // we cannot change ci; const is top-levelint i = ci; // ok: when we copy ci, its top-level const is ignoredint * const p = &i; // const is top-level; we can't assign to p*p = 0; // ok: changes through p are allowed; i is now 0
Just as in any other initialization, when we copy an argument to initialize a parameter, top-level consts are ignored. As ...
Read now
Unlock full access