EECS 211
How to read Chapter 8

Chapter 8 is about pointers and C-style strings. Pointers and pointer arithmetic are a programming technique not found in most programming languages.

Pointers are a common source of programmer error. These errors are often fatal to the program and even to the operating system on which its running. As a result, several features have been added to C++ to reduce the need for explicitly managing pointers:

As a result, common reasons for using pointers in modern C++ code are:

One key thing to understand about pointer arithmetic is that it's based on the type of the pointer. If ptr is a pointer to objects of type type, then

ptr + 1 = ptr + sizeof(type)

That's why ++ptr properly advances a pointer to one element of an array to the next element, no matter how big the elements are.

The other thing to understand about pointers is the difference between constant pointers and pointers to constants. The book talks about this is detail in Section 8.5. A succinct very readable discussion is at the C++ FAQ.