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.
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; //Both *foo and *foo are pointers.