Raw Pointers
A pointer is a variable that stores a memory address, allowing indirect access to other variables.
References
A reference is an alias - another name for an existing object. Unlike pointers, references cannot be null, must be initialized, and cannot be reseated.
Pointer Arithmetic
Pointer arithmetic navigates contiguous memory with automatic scaling by type size. Essential for arrays but dangerous without bounds checking.
const Pointers
const with pointers creates three distinct scenarios. Understanding the difference prevents bugs and documents intent.
unique_ptr
Smart pointer with exclusive ownership. Zero overhead, automatic cleanup, move-only semantics. The default choice for dynamic memory.
shared_ptr
Smart pointer with shared ownership via reference counting. Multiple shared_ptrs can own the same object, deleted when last owner destroyed.
weak_ptr
Non-owning observer of shared_ptr-managed objects. Doesn't increase reference count, enables checking if object still exists.
Custom Deleters
Extend smart pointers to manage any resource requiring special cleanup beyond delete. Enable RAII for files, handles, connections, locks - anything needing cleanup.