O'Reilly logo

The C++ Programming Language, Special Edition by New Jersey Stroustrup Bjarne AT&T Labs Murray Hill

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

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

Pointers

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:

Pointers

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

int* pi;               // pointer to ...

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