A complete, working C++
Every code sample on this site compiles and runs in your browser. Every hard idea — ownership, lifetime, moves, templates — comes with a diagram of what the machine is actually doing, and problems that check your answer by running it.
84 chapters · 84 written · 205 problems
Three ways to read this
New to programming
Read Parts 1–4 in order. They assume nothing: no compiler installed, no terminal experience, no maths beyond arithmetic.
Begin →You know another language
Skim Part 1, then start at the memory model. That is where C++ stops resembling Python or Java and starts asking you to make decisions.
Start with memory →You want the problems
The problem bank is filterable by topic and difficulty, and each problem compiles and tests your submission. Your progress is saved in this browser.
Open the bank →Contents
-
Part 1
Foundations
What a program is, what the compiler does with it, and the handful of constructs every later chapter assumes. Nothing here presumes you have programmed before.
-
Part 2
Memory and objects
The part of C++ that other languages hide from you. Everything from here on — copies, moves, containers, performance — is a consequence of what is in this part.
-
Part 3
Types you make
How to build a type that behaves as well as a built-in one: it copies correctly, cleans up after itself, and cannot be misused by accident.
-
Part 4
The standard library
The containers, algorithms, and utilities that mean you rarely need to write a loop or manage memory by hand.
-
Part 5
Generic programming
Writing code once that works for every type it makes sense for, with errors that name the real problem.
-
Part 7
Performance
Making programs fast on the machines that exist, based on measurement rather than folklore.
-
Part 9
Building real software
Everything between a single file that compiles and a project other people can build, depend on, and change.
-
Part 10
Problem solving
The techniques competitive programming is built on, taught against the constraint that decides which one you need — and drilled on a judge.
- 10.1 Reading a problem
- 10.2 Counting the work
- 10.3 Template and fast I/O
- 10.4 Sorting and comparators
- 10.5 Binary search
- 10.6 Two pointers
- 10.7 Prefix sums
- 10.8 Monotonic stacks
- 10.9 Monotonic deques
- 10.10 Hashing and counting
- 10.11 Recursion
- 10.12 Bitmasks
- 10.13 Greedy
- 10.14 Divide and conquer
- 10.15 Meet in the middle
- 10.16 Representing graphs
- 10.17 BFS
- 10.18 DFS
- 10.19 Topological order
- 10.20 Union-Find
- 10.21 Dijkstra
- 10.22 Negative weights
- 10.23 Spanning trees
- 10.24 Tree DP