C++
Modern, portable C++ (C++17/20/23) learned by programming, plus the whole toolchain underneath it, on Windows, macOS, and Linux.
Free to read now, no account needed: Before you start: programs, files, and the terminal. Create a free account to open the other chapters, take the quizzes and keep your progress.
My setup
Lessons that differ by operating system or tool show your choice first, and fold away notes meant for other setups. You can switch tabs in any lesson β it remembers what you pick.
Operating system
Tools
Compiler
1 Set up your toolchain π
Create a free account to open this chapter.
- Compilers, IDEs, and build tools ~18 min
- Install a compiler ~30 min
- Your first program ~25 min
- Building in an IDE ~25 min
2 How a C++ program is built π
Create a free account to open this chapter.
- The build pipeline ~22 min
- Headers and translation units ~25 min
- Reading compiler errors ~25 min
- Choosing a C++ standard ~20 min
- Works on my compiler ~22 min
3 Values, types, and variables π
Create a free account to open this chapter.
- Variables and memory ~18 min
- The fundamental types ~22 min
- Initialization and narrowing ~22 min
- const, constexpr, and auto ~26 min
- Conversions and casts ~25 min
4 Input, output, and strings π
Create a free account to open this chapter.
- Printing output ~18 min
- Reading input ~22 min
- Strings ~25 min
- Formatting output ~22 min
5 Operators, expressions, and control flow π
Create a free account to open this chapter.
- Comparisons and logic ~20 min
- if and switch ~22 min
- while loops and validating input ~25 min
- for loops ~25 min
- Named choices: enum class ~25 min
6 Functions π
Create a free account to open this chapter.
- Defining and calling functions ~22 min
- Parameters and return values ~28 min
- Overloading and default arguments ~20 min
- Recursion and the call stack ~22 min
- Functions across files ~22 min
7 Scope, lifetime, and the stack π
Create a free account to open this chapter.
- Block scope and shadowing ~22 min
- Lifetime and the stack ~24 min
- Static local variables ~20 min
- Global variables and why to avoid them ~20 min
- Namespaces ~22 min
8 Arrays, vectors, and strings in depth π
Create a free account to open this chapter.
- Contiguous storage and std::array ~24 min
- Indexing and bounds: [] versus at() ~27 min
- std::vector: a row that grows ~36 min
- Growth and capacity ~27 min
- std::string in depth, and a first look at std::string_view ~42 min
9 References π
Create a free account to open this chapter.
- References are aliases ~20 min
- Passing by reference ~22 min
- const references: cheap and safe ~22 min
- Returning references, and dangling ones ~24 min
- Value semantics and reference semantics ~22 min
10 Pointers and memory π
Create a free account to open this chapter.
- Addresses and pointers ~24 min
- Null, dangling, and where objects live ~26 min
- Pointer arithmetic over arrays ~24 min
- Pointers versus references ~24 min
- std::span ~24 min
11 Structs and classes π
Create a free account to open this chapter.
- Structs and aggregates ~36 min
- Member functions and access control ~30 min
- Constructors and invariants ~42 min
- Const member functions and this ~31 min
- Destructors and object lifetime ~22 min
- Operator overloading and comparisons ~38 min
12 Dynamic memory, ownership, and RAII π
Create a free account to open this chapter.
- The heap: new and delete ~22 min
- Leaks, dangling pointers, and double frees ~24 min
- RAII: let the destructor clean up ~22 min
- std::unique_ptr: one owner ~24 min
- std::shared_ptr, std::weak_ptr, and choosing an owner ~26 min
13 Copy, move and the Rule of 0/3/5 π
Create a free account to open this chapter.
- Copying objects ~22 min
- Deep and shallow copies ~25 min
- Rvalues and std::move ~24 min
- Move constructor and move assignment ~26 min
- The Rule of Zero, = default and = delete ~24 min
14 Multi-file projects and CMake fundamentals π
Create a free account to open this chapter.
- Laying out a project ~22 min
- Declarations, definitions and the One Definition Rule ~26 min
- Include guards and #pragma once ~20 min
- Your first real CMakeLists.txt ~28 min
- Build folders, rebuilds, Debug and Release ~26 min
- Version control for a C++ project ~32 min
15 The standard library: containers and iterators π
Create a free account to open this chapter.
- Iterators: a position in a container ~24 min
- Sequence containers: deque and list ~26 min
- Maps: finding a value by its key ~28 min
- Sets, and choosing a container ~24 min
- Iterator invalidation ~28 min
16 Algorithms, lambdas and ranges π
Create a free account to open this chapter.
- The standard algorithms ~24 min
- Lambdas ~26 min
- Captures, and the dangling lambda ~28 min
- std::function and callbacks ~26 min
- Ranges, views and pipelines ~32 min
- Random numbers and time: <random> and <chrono> ~30 min
17 Error handling π
Create a free account to open this chapter.
- Throwing and catching exceptions ~28 min
- Stack unwinding, RAII, and noexcept ~28 min
- std::optional: a value or nothing ~24 min
- std::expected: a value or the reason why not ~26 min
- std::variant, std::visit, and choosing a strategy ~28 min
18 Inheritance and polymorphism π
Create a free account to open this chapter.
- Base and derived classes ~25 min
- Virtual functions and override ~28 min
- Virtual destructors ~22 min
- Abstract classes and interfaces ~25 min
- Slicing, and when not to inherit ~30 min
19 Templates and concepts π
Create a free account to open this chapter.
- Function templates ~24 min
- Type deduction and auto parameters ~24 min
- Class templates ~26 min
- Concepts and requires ~30 min
- Reading template errors ~26 min
20 Files and the filesystem π
Create a free account to open this chapter.
- Writing files ~36 min
- Reading a file to the end ~26 min
- Text and binary files ~24 min
- Paths and std::filesystem ~26 min
- Scanning folders and parsing CSV ~30 min
21 Debugging, warnings, sanitizers and static analysis π
Create a free account to open this chapter.
- Breakpoints, stepping and the call stack ~28 min
- Watches, conditional breakpoints and memory ~28 min
- Compiler warnings, and two compilers side by side ~26 min
- Sanitizers ~32 min
- Static analysis, and choosing the right tool ~26 min
- Style, formatting and naming ~26 min
22 Testing π
Create a free account to open this chapter.
- Why automated tests ~24 min
- Running tests with CTest ~30 min
- GoogleTest and Catch2 ~32 min
- Test-first bug fixing ~28 min
- Testing a library target ~30 min
23 Build systems in depth π
Create a free account to open this chapter.
- Targets and usage requirements ~30 min
- Generators and CMake presets ~30 min
- Ninja and incremental builds ~28 min
- Visual Studio projects and MSBuild ~28 min
- Reading a Makefile ~28 min
- Keeping builds fast ~35 min
24 Dependencies and the library ecosystem π
Create a free account to open this chapter.
- What a dependency is, and how CMake finds one ~30 min
- FetchContent, building a dependency from source ~28 min
- vcpkg in manifest mode ~30 min
- Conan 2 ~28 min
- A tour of popular libraries ~25 min
25 Writing libraries for Windows, macOS, and Linux π
Create a free account to open this chapter.
- Static, shared, and header-only libraries ~26 min
- Exporting symbols ~28 min
- Finding shared libraries at run time ~30 min
- ABI boundaries: extern "C" and pimpl ~32 min
- install(), export(), and find_package ~32 min
- Designing and documenting a public API ~34 min
26 Portability, concurrency and modern extras π
Create a free account to open this chapter.
- Portable types, byte order and platform code ~26 min
- Undefined, unspecified and implementation-defined ~26 min
- Threads, data races and mutexes ~30 min
- Atomics, async and ThreadSanitizer ~30 min
- Compile-time code, and what comes next ~30 min
27 Capstone: the cross-platform project π
Create a free account to open this chapter.
- Plan before you code ~35 min
- The design, revealed ~32 min
- Building it three ways ~34 min
- Presets and a CI matrix ~34 min
- The definition of done ~30 min
Appendices
Reference chapters on the tools the course uses. Dip in when a lab or a section sends you here; they are not part of the course exam.
A Appendix A: Old Way and Modern Way -- a field guide to legacy C++ π
Create a free account to open this chapter.
- Arrays, strings and pointers ~22 min
- Memory and ownership ~22 min
- Constants, casts, type names and printf ~24 min
- Errors, callbacks and generic code ~26 min
- Headers, builds and threads ~22 min
B Appendix B: Toolchain quick-reference cards π
Create a free account to open this chapter.
- Compile, link, and run ~18 min
- Warnings and language standards ~18 min
- Debug, release, and sanitizer builds ~20 min
- CMake and CTest ~22 min
- Debugger commands ~20 min
- Reading the assembly ~18 min
- Modern C++ defaults ~20 min
C Appendix C: Talking to C π
Create a free account to open this chapter.
- extern "C" and linkage ~22 min
- C strings at the boundary ~24 min
- malloc and free ~22 min
- Wrapping a C library ~30 min
D Appendix D: Data structures and Big-O π
Create a free account to open this chapter.
- Counting steps, and Big-O ~22 min
- A linked list with unique_ptr ~25 min
- A hash map from vectors ~25 min
- A binary heap on a vector ~24 min
- Measuring, with counts and with a clock ~22 min