© Mikael Olsson 2020
M. OlssonC++20 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-5995-5_5

5. Pointers

Mikael Olsson1 
(1)
Hammarland, Finland
 

A pointer is a variable that contains the memory address of another variable, function, or object, called the pointee.

Creating Pointers

Pointers are declared as any other variable, except that an asterisk (*) is placed between the data type and the pointer’s name. The data type used determines what type of memory it will point to. More than one pointer can be created in the same statement using the comma operator. The asterisk must then be placed before each identifier and not after the type.
int* p; // pointer to an integer
int *q; // alternative syntax
int *a, *b, *c; // multiple pointers
A pointer ...

Get C++20 Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library 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.