Pointers

suggest change

A pointer is an address that refers to a location in memory. They’re commonly used to allow functions or data structures to know of and modify memory without having to copy the memory referred to. Pointers are usable with both primitive (built-in) or user-defined types.

Pointers make use of the “dereference” * , “address of” & , and “arrow” -> operators. The ‘*’ and ‘->’ operators are used to access the memory being pointed at, and the & operator is used to get an address in memory.

Syntax

Be aware of problems when declaring multiple pointers on the same line.

int* a, b, c; //Only a is a pointer, the others are regular ints.

int* a, *b, *c; //These are three pointers!

int *foo[2]; //Both *foo[0] and *foo[1] are pointers.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Pointers:
* Syntax

Table Of Contents
8 Arrays
11 Loops
17 Pointers
39 Streams
51 Unions
56 Lambdas
60 SFINAE
62 RAII
67 Sorting
84 RTTI
87 Scopes
104 Profiling
107 Recursion
117 Iteration
125 Alignment
134 Semaphore
136 Debugging
139 Mutexes
142 decltype