O'Reilly logo

C++ Primer, Fifth Edition by Barbara E. Moo, Josée Lajoie, Stanley B. Lippman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

2.4.3. Top-Level const

Image

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 const.

Exercises Section 2.4.2

Exercise 2.27: Which of the following initializations are legal? Explain why.

(a) int i = -1, &r = 0;

(b) int *const p2 = &i2;

(c) const int i = -1, &r = 0;

(d) const int *const p3 = &i2;

(e) const int *p1 = &i2;

(f) const int &const ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required