AI InterviewSearch…Search problems, topics, or pages…Ctrl KGet started

C++

The language of systems, engines and the hard rounds — types and memory, RAII and ownership, classes and the rule of five, templates, the STL, concurrency and modern C++ — with exercises judged on a real C++20 compiler.

20 modules · 131 lessons · ~35 h · exercises run on Clang 18 · C++20

Syllabus

Nothing is locked. Every module has a PDF.

01

C++ and the toolchain

you are here
Where C++ came from and the zero-overhead principle, the preprocess-compile-assemble-link pipeline, the anatomy of a program, the console I/O patterns every exercise uses, and how to read what the compiler says.
0/6 · 94 minPDF
02

Fundamental types

The built-in types and their exact sizes on this platform; integer overflow, wrap-around and bits; floating-point representation and deterministic printing; conversions and the four casts; const, constexpr and auto; literals and scoped enums.
0/7 · 111 minPDF
03

Control flow

if/else and the conditional operator, switch with fallthrough and enums, the three loops and the unsigned countdown trap, range-based for with auto& and structured bindings, and the loop patterns every program is built from.
0/6 · 92 minPDF
04

Functions

Declarations and definitions, the three ways to pass a parameter, overloading and default arguments, recursion with memoisation, a first look at lambdas, and scope, lifetime and linkage.
0/7 · 107 minPDF
05

Strings

std::string as a value type, the find family and slicing, characters and numeric conversions, parsing input, formatting output with iomanip and std::format, and std::string_view.
0/7 · 107 minPDF
06

Arrays, pointers and references

Built-in arrays and std::array, pointers and nullptr, pointer arithmetic and the [begin, end) range, references and dangling, const correctness read right to left, and 2-D grids with a neighbour loop.
0/7 · 109 minPDF
07

Memory, ownership and RAII

Storage durations and the stack-frame picture, new/delete and the ownership contract, RAII and why C++ needs no finally, std::unique_ptr and std::shared_ptr with std::weak_ptr, and the memory-error catalogue with the sanitizers that find it.
0/7 · 113 minPDF
08

Classes and objects

Structs, aggregates and designated initialisers; constructors, the member-initialiser list and declaration-order initialisation; this, const member functions, mutable and chaining; static members and named constructors; invariants, friends and operator<<; the header/source split and a worked class design.
0/7 · 109 minPDF
09

Copies, moves and the rule of five

Copy construction versus assignment and the memberwise defaults, destructors and the rule of three, copy-and-swap, rvalue references and std::move, the moved-from state and noexcept, the generation table behind the rule of five and the rule of zero, and value categories with guaranteed elision.
0/6 · 100 minPDF
10

Inheritance and polymorphism

Deriving and the order of construction, virtual functions with override and final, abstract classes and interfaces held through unique_ptr, virtual destructors and slicing, the vtable, dynamic_cast and std::variant, and when composition beats inheritance.
0/7 · 111 minPDF
11

Operator overloading

Which operators to overload and where they live, the compound-first idiom, == and the C++20 spaceship with its ordering categories, << and >> that respect the stream, operator[] and operator() with functors and std::hash, and explicit on constructors and conversions.
0/6 · 97 minPDF
12

Templates and generic programming

Function templates and deduction, Stack<T> and Pair<A, B> with CTAD, full and partial specialisation and the traits pattern, non-type parameters and fold expressions, C++20 concepts with constrained auto, and the type traits behind if constexpr dispatch.
0/7 · 113 minPDF
13

STL containers

The four container families and their complexity table, std::vector's size–capacity model and the erase–remove idiom, deque, list and the adaptors, std::map and std::set with lower_bound, the unordered containers with custom hashes, and iterators with the invalidation table.
0/7 · 106 minPDF
14

Algorithms and lambdas

The half-open range and predicate interface of <algorithm> and <numeric>, sorting with comparators and binary search, transform/accumulate/partition, lambdas as closure objects with std::function, and C++20 ranges with lazy views.
0/6 · 99 minPDF
15

Errors and exceptions

throw, try and catch with the standard hierarchy and your own, the three exception-safety guarantees with RAII and noexcept, std::optional for absence, std::variant with std::visit for one-of-several, and error codes, assertions and a per-layer strategy.
0/6 · 94 minPDF
16

Modern C++

The standards from C++11 to C++23 and what compiles here; auto, decltype and structured bindings; constexpr, consteval and compile-time tables; the vocabulary types from tuple to span and chrono; concepts, ranges, <=> and std::format, with C++23 as reading.
0/6 · 98 minPDF
17

Concurrency

std::thread and std::jthread with the join rule; data races and the RAII locks; atomics and compare-exchange; condition variables and a bounded queue; futures, promises and std::async; a thread pool, split-and-reduce and the deterministic-output rule for judged programs.
0/7 · 112 minPDF
18

Streams and files

The stream state model and recovering from bad input, the reading-pattern catalogue with validation, file streams and open modes, string streams with std::quoted and std::format, binary records and std::filesystem.
0/6 · 98 minPDF
19

Performance and undefined behaviour

The undefined-behaviour catalogue and the well-defined detectors for it, the cost model of copies, allocations and calls, cache lines, padding and traversal order, what -O2 does under the as-if rule, and how to measure without being lied to.
0/6 · 97 minPDF
20

Interview idioms

The contest template and what it costs, the STL idiom sheet, the pitfalls that fail interviews, implementing vector and a hash map by hand, clean solutions under pressure, and the C++ theory drill.
0/7 · 123 minPDF

Learn C++: Free C++ Tutorial in 131 Lessons

Learn C++ free: 131 lessons in 20 modules, from first programs to interview questions, with exercises judged on Clang 18 · C++20 and a certificate.

  • Language: C++
  • Runtime: Clang 18 · C++20
  • Modules: 20
  • Lessons: 131
  • Reading time: about 35 hours
  • Cost: Free on every plan, with a certificate

The language of systems, engines and the hard rounds — types and memory, RAII and ownership, classes and the rule of five, templates, the STL, concurrency and modern C++ — with exercises judged on a real C++20 compiler.

Syllabus

Module 1: C++ and the toolchain

Where C++ came from and the zero-overhead principle, the preprocess-compile-assemble-link pipeline, the anatomy of a program, the console I/O patterns every exercise uses, and how to read what the compiler says.

Module 2: Fundamental types

The built-in types and their exact sizes on this platform; integer overflow, wrap-around and bits; floating-point representation and deterministic printing; conversions and the four casts; const, constexpr and auto; literals and scoped enums.

Module 3: Control flow

if/else and the conditional operator, switch with fallthrough and enums, the three loops and the unsigned countdown trap, range-based for with auto& and structured bindings, and the loop patterns every program is built from.

Module 4: Functions

Declarations and definitions, the three ways to pass a parameter, overloading and default arguments, recursion with memoisation, a first look at lambdas, and scope, lifetime and linkage.

Module 5: Strings

std::string as a value type, the find family and slicing, characters and numeric conversions, parsing input, formatting output with iomanip and std::format, and std::string_view.

Module 6: Arrays, pointers and references

Built-in arrays and std::array, pointers and nullptr, pointer arithmetic and the [begin, end) range, references and dangling, const correctness read right to left, and 2-D grids with a neighbour loop.

Module 7: Memory, ownership and RAII

Storage durations and the stack-frame picture, new/delete and the ownership contract, RAII and why C++ needs no finally, std::unique_ptr and std::shared_ptr with std::weak_ptr, and the memory-error catalogue with the sanitizers that find it.

Module 8: Classes and objects

Structs, aggregates and designated initialisers; constructors, the member-initialiser list and declaration-order initialisation; this, const member functions, mutable and chaining; static members and named constructors; invariants, friends and operator<<; the header/source split and a worked class design.

Module 9: Copies, moves and the rule of five

Copy construction versus assignment and the memberwise defaults, destructors and the rule of three, copy-and-swap, rvalue references and std::move, the moved-from state and noexcept, the generation table behind the rule of five and the rule of zero, and value categories with guaranteed elision.

Module 10: Inheritance and polymorphism

Deriving and the order of construction, virtual functions with override and final, abstract classes and interfaces held through unique_ptr, virtual destructors and slicing, the vtable, dynamic_cast and std::variant, and when composition beats inheritance.

Module 11: Operator overloading

Which operators to overload and where they live, the compound-first idiom, == and the C++20 spaceship with its ordering categories, << and >> that respect the stream, operator[] and operator() with functors and std::hash, and explicit on constructors and conversions.

Module 12: Templates and generic programming

Function templates and deduction, Stack<T> and Pair<A, B> with CTAD, full and partial specialisation and the traits pattern, non-type parameters and fold expressions, C++20 concepts with constrained auto, and the type traits behind if constexpr dispatch.

Module 13: STL containers

The four container families and their complexity table, std::vector's size–capacity model and the erase–remove idiom, deque, list and the adaptors, std::map and std::set with lower_bound, the unordered containers with custom hashes, and iterators with the invalidation table.

Module 14: Algorithms and lambdas

The half-open range and predicate interface of <algorithm> and <numeric>, sorting with comparators and binary search, transform/accumulate/partition, lambdas as closure objects with std::function, and C++20 ranges with lazy views.

Module 15: Errors and exceptions

throw, try and catch with the standard hierarchy and your own, the three exception-safety guarantees with RAII and noexcept, std::optional for absence, std::variant with std::visit for one-of-several, and error codes, assertions and a per-layer strategy.

Module 16: Modern C++

The standards from C++11 to C++23 and what compiles here; auto, decltype and structured bindings; constexpr, consteval and compile-time tables; the vocabulary types from tuple to span and chrono; concepts, ranges, <=> and std::format, with C++23 as reading.

Module 17: Concurrency

std::thread and std::jthread with the join rule; data races and the RAII locks; atomics and compare-exchange; condition variables and a bounded queue; futures, promises and std::async; a thread pool, split-and-reduce and the deterministic-output rule for judged programs.

Module 18: Streams and files

The stream state model and recovering from bad input, the reading-pattern catalogue with validation, file streams and open modes, string streams with std::quoted and std::format, binary records and std::filesystem.

Module 19: Performance and undefined behaviour

The undefined-behaviour catalogue and the well-defined detectors for it, the cost model of copies, allocations and calls, cache lines, padding and traversal order, what -O2 does under the as-if rule, and how to measure without being lied to.

Module 20: Interview idioms

The contest template and what it costs, the STL idiom sheet, the pitfalls that fail interviews, implementing vector and a hash map by hand, clean solutions under pressure, and the C++ theory drill.