C++20 — 8 Modules · 60+ Examples

C++ from Basics to Modern.

The performance ceiling of general-purpose programming — compiled straight to machine code, with no garbage collector between you and the hardware. Types and the STL, pointers and memory, OOP with RAII, templates, and the smart pointers that make modern C++ safe.

C++20 60+ runnable examples Zero-cost abstractions Manual memory
8 Modules Basics → Practice
60+ Examples Runnable code snippets
4 OOP Pillars Plus RAII
40 Practice Programs Basic → Advanced
Open the C++ roadmap Every module and the sections inside it as one connected flow chart, in the order this track teaches them. Explore →
Curriculum

All 8 C++ modules

Follow the path top-to-bottom or jump to the module you need.

Module 01
C++ Basics
TypesautoReferences
Where every C++ journey starts. Fundamental types that map to memory, auto inference, const, and references.
Starter level
Learn →
Module 02
Control Flow
if/switchLoopsrange-for
Conditionals, switch with its fall-through trap, and the clean range-based for loop.
Starter level
Learn →
Module 03
STL Containers
vectormapset
The Standard Template Library — vector, string, map, and set. Fast, type-safe, and the backbone of interviews.
Starter level
Learn →
Module 04
Functions
OverloadingBy ref/valueLambdas
Overloading, default arguments, the pass-by-value-vs-reference choice that defines C++ performance, and lambdas.
Mid level
Learn →
Module 05
Pointers & Memory
PointersStack/Heapnew/delete
The module that defines C++. Pointers, the stack/heap split, manual allocation, and the leaks and dangling pointers to avoid.
Mid level
Learn →
Module 06
Object-Oriented C++
RAIIRule of 5virtual
The four pillars plus RAII, the rule of three/five, and opt-in polymorphism through virtual functions.
Mid level
Learn →
Module 07
Templates & STL Algorithms
TemplatesGeneric codealgorithm
Generic code with zero runtime cost — function and class templates, and the algorithm header the whole STL is built on.
Advanced
Learn →
Module 08
Modern C++
Smart pointersMoveauto
C++11 through C++20 — smart pointers, move semantics, and type inference that make C++ memory-safe and readable.
Advanced
Learn →
Module 09
Practice Programs
AlgorithmsSTLRAII
40 hands-on programs from basic to advanced — sorting, a template stack, a RAII bank account, and a unique_ptr linked list.
Advanced
Practice →
Why C++?

Where performance is non-negotiable

For game engines, systems, high-frequency trading, and competitive programming — C++ is where the speed ceiling lives.

Maximum Performance
Compiles to native code with no runtime overhead. When every microsecond counts, C++ is the default answer.
Game Engines
Unreal Engine, and most AAA game code, is C++. Real-time rendering needs the control and speed only C++ provides.
Systems & Embedded
Operating systems, databases, browsers, and firmware run on C++. Direct memory control is a feature, not a bug, at that level.
Competitive Programming
The dominant language of contests. Fast execution plus the STL makes it the tool of choice for ICPC and Codeforces.
Zero-Cost Abstractions
Templates and RAII give you high-level expressiveness that compiles away to nothing. You pay only for what you use.
Interview Depth
C++ interviews probe memory, pointers, RAII, and the rule of five — concepts that sharpen how you think about all code.
Watch Out

C++ gotchas that trip up interviews

Common surprises — know these cold before your next interview.

DANGLING POINTER
int* p = new int(5);
delete p;
*p = 10;   // UB — p points at freed memory
Using memory after delete is undefined behavior. Set pointers to nullptr, or better, use smart pointers.
INTEGER DIVISION
5 / 2       // 2   — both ints, truncated
5.0 / 2     // 2.5 — one double is enough
int / int truncates toward zero. Make one operand a double for real division.
vector[i] OUT OF BOUNDS
std::vector<int> v(3);
v[10];    // UB — no bounds check
v.at(10); // throws std::out_of_range ✓
operator[] does no bounds checking. Use .at() when you want a thrown exception instead of silent corruption.
MISSING virtual DESTRUCTOR
class Base { /* no virtual ~Base */ };
Base* p = new Derived();
delete p;   // only ~Base runs — Derived part leaks
A base class deleted through a base pointer needs a virtual destructor, or the derived part never gets cleaned up.
Code Preview

Taste the content

Three patterns from across the curriculum — click to switch.

cpp_examples.cpp
Smart Pointers
Templates
RAII
// Smart pointers — memory safety without a garbage collector
#include <memory>

auto p = std::make_unique<int>(42);   // sole owner
*p;   // 42
// no delete needed — freed automatically at end of scope

auto a = std::make_shared<int>(10);   // reference-counted
auto b = a;                            // two owners, count = 2
a.use_count();   // 2 — freed only when both are gone
// Templates — generic code with zero runtime cost
template<typename T>
T maximum(T a, T b) {
    return a > b ? a : b;
}

maximum(3, 7);          // 7   — T deduced as int
maximum(2.5, 1.5);      // 2.5 — T deduced as double
// compiler stamps out a specialized, inlined version per type
// RAII — cleanup tied to scope, no manual delete
class File {
    FILE* handle;
public:
    File(const char* name) { handle = fopen(name, "r"); }
    ~File() { if (handle) fclose(handle); }   // runs automatically
};

{
    File f("data.txt");   // opened
}   // closed here — even if an exception was thrown
C++ is the competitive-programming language
Its speed and STL make it the default for coding contests and DSA interviews. Pair this track with the DSA section to practice algorithms in the language that runs them fastest.
C++ Interview →