As we’ve seen, a pointer is an object that can point to a different object. As a result, we can talk independently about whether a pointer is
const and whether the objects to which it can point are
const. We use the term top-level
const to indicate that the pointer itself is a
const. When a pointer can point to a
const object, we refer to that
const as a low-level
Exercise 2.27: Which of the following initializations are legal? Explain why.
int i = -1, &r = 0;
int *const p2 = &i2;
const int i = -1, &r = 0;
const int *const p3 = &i2;
const int *p1 = &i2;
const int &const ...
Get C++ Primer, Fifth Edition 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.