Category

Dynamic Memory and RAII

Stack Memory Versus Heap Memory

Any value produced by a program takes up space in memory. The language carves the program's address space up into several divisions, each with different rules f…

Jul 14, 2026 →

Dynamic Allocation with new and delete

Local variables exist only as long as the block that created them. For a value to persist beyond that point, or for the case where the number of objects cannot…

Jul 14, 2026 →

Dynamically Allocated Arrays

An ordinary array has to have a predetermined length at compile time. If the number of elements can only be known at runtime, or you want your array to have a l…

Jul 14, 2026 →

Memory Leaks, Double Deletion, and Use After Free

When you dynamically allocate an object, you have much more control over its lifetime, and this control also happens to create three classic mistakes very few l…

Jul 14, 2026 →

Resource Ownership

When a program takes possession of some resource which the language will not automatically free for you, someone has to take responsibility for freeing it. Owne…

Jul 14, 2026 →

Introduction to RAII

A manual release of a resource only occurs when all paths of the code remember to release the resource. Even one early return, lost error path, or simple omissi…

Jul 15, 2026 →

Why Modern C++ Avoids Manual Memory Management

Important: This lesson uses classes in the code examples which we haven't covered yet, so you can SKIP it until you learn about classes, in the Classes and Obje…

Jul 15, 2026 →
About CppLearn

CppLearn is an interactive, free reference for modern C++. In each lesson, you'll find out how the language works, rather than just lines of code that you can copy and paste. We cover concepts starting from beginner lessons on fundamentals and proceed to templates, move semantics, smart pointers, and areas that usually trap or scare C++ learners.