Pointer

Applies to: cpp

A pointer holds the memory address of a value. You dereference it with * to read/write the pointed-to value, and -> to access a member through it. Pointers enable dynamic data structures but require care (null, dangling, ownership).

int x = 5;
int* p = &x;     // p holds x's address
*p = 7;          // writes through the pointer: x == 7

See also: reference, raii