A pointer is a variable that stores the memory address of an object or variable.
Pointers are used extensively in both C and C++ for three main purposes:
- to allocate new objects on the heap,
- to pass functions to other functions.
- to iterate over elements in arrays or other data structures.
Syntax:
int *p; // An integer pointer int x = 5; *p = x; // *p "points" to x cout << *p; // Prints 5 *ch; // A character pointer
