© Mikael Olsson 2018
Mikael OlssonC++17 Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-3600-0_5

5. Pointers

Mikael Olsson1 
Hammarland, Finland

A pointer is a variable that contains the memory address of another variable 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.

int* p; // pointer to an integer
int *q; // alternative syntax

A pointer can point to a variable of the same type by prefixing that variable with an ampersand, in order to retrieve its address and assign it to the pointer. The ampersand is known as the address-of operator ( ...

Get C++17 Quick Syntax Reference: A Pocket Guide to the Language, APIs and Library now with O’Reilly online learning.

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