Chapter 5. Pointers, Arrays, and Structures


The sublime and the ridiculous are often so nearly related that it is difficult to class them separately.

 --Tom Paine


For a type T, T* is the type “pointer to T.” That is, a variable of type T* can hold the address of an object of type T. For example:

char c = 'a';
char* p = &c;        // p holds the address of c

or graphically:


Unfortunately, pointers to arrays and pointers to functions need a more complicated notation:

int* pi;               // pointer to ...

Get The C++ Programming Language, Special Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.