Skip to Main Content
C++ Primer, Fifth Edition
book

C++ Primer, Fifth Edition

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

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

Publisher Resources

ISBN: 9780133053043Purchase Link