Loading...

Memory and Pointers

Articles covering pointers, references, dynamic memory management, and addressing in C++.

Memory and Pointers

The low-level power of C++: addressing, pointers and references; stack vs. heap; and dynamic memory management. Explore the risks of new/delete, safe patterns, and techniques to prevent memory leaks.

Goal: Apply addressing and dynamic memory correctly to write safe, bug-free C++ code.

TL;DR

  • Pointers & references: int* p, int& r, nullptr.
  • Dynamic memory: new/delete, new[]/delete[].
  • Arrays & pointer arithmetic: *(p + i).
  • Habits/tools: RAII; stepping stone to std::unique_ptr.