C++ Demo Examples
These demos go beyond the one-liners in the lessons — each combines several ideas into one working program you can break and fix. Only the standard library is used, so nothing extra needs installing. Build with any C++17 compiler:
# GCC or Clang
g++ -std=c++17 -Wall -Wextra 01_types_and_operators.cpp -o demo01 && ./demo01
# the concurrency demos (11, 12) need the threading library
g++ -std=c++17 -Wall -Wextra -pthread 11_threads_mutex.cpp -o demo11 && ./demo11
# on Windows with MSVC
cl /std:c++17 /EHsc 01_types_and_operators.cpp
Foundations
Types, operators and control flow — the primitives every other demo builds on.
| # | Description | Link |
|---|---|---|
| 1 | Types, Size and Operators | View |
| 2 | Control Flow Patterns | View |
Functions & References
Parameter passing, overloading, and the practical difference between references and pointers.
| # | Description | Link |
|---|---|---|
| 3 | Functions, Overloads & Defaults | View |
| 4 | References & Pointers | View |
Objects & RAII
Classes that enforce an invariant, and RAII — the pattern that makes C++ cleanup automatic.
| # | Description | Link |
|---|---|---|
| 5 | Classes, Invariants & RAII | View |
| 6 | Inheritance & Polymorphism | View |
Containers & Algorithms
Choose the right STL container, then let algorithms and lambdas replace hand-written loops.
| # | Description | Link |
|---|---|---|
| 7 | Containers: vector, map, set | View |
| 8 | Algorithms & Lambdas | View |
Modern C++
Move semantics and templates — the features that make modern C++ fast and generic.
| # | Description | Link |
|---|---|---|
| 9 | Move Semantics (copy vs move) | View |
| 10 | Templates & Generics | View |
Concurrency
Threads, data races, mutexes, atomics and task-based parallelism.
| # | Description | Link |
|---|---|---|
| 11 | Threads & Mutex (data races) | View |
| 12 | async, future & atomic | View |
Enterprise Patterns
Production building blocks: structured logging with RAII, and the Observer pattern.
| # | Description | Link |
|---|---|---|
| 13 | Logging & RAII Timing Guard | View |
| 14 | Observer / Event Bus | View |