August 2012
Intermediate to advanced
976 pages
30h 17m
English
const ParametersAs we saw in § 6.2.3 (p. 212), top-level const (§ 2.4.3, p. 63) has no effect on the objects that can be passed to the function. A parameter that has a top-level const is indistinguishable from one without a top-level const:
Record lookup(Phone);Record lookup(const Phone); // redeclares Record lookup(Phone)Record lookup(Phone*);Record lookup(Phone* const); // redeclares Record lookup(Phone*)
In these declarations, the second declaration declares the same function as the first.
On the other hand, we can overload based on whether the parameter is a reference (or pointer) to the const or nonconst version of a ...
Read now
Unlock full access