Pointers, References, and Arrays

Astute readers will recall seeing something like the preceding definitions earlier in the book—for instance, in the arguments to main():

char* argv[]

Or the argument to UserWantsToContinueYorN():

char *theThingWeAreDoing

But what is the meaning of * in these definitions? In a definition, * should be read as “pointer to,” so we can read these two lines as “pointer to an array of characters” and “pointer to a character,” respectively.

Figure 13.3 shows how pointers “point” to storage on the heap.

Figure 13.3. Pointers have a location in the heap as their value.

* is also a prefix operator that can be used outside ...

Get SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.