1 · Introduction to C++

C++ is a powerful, multiparadigm language that supports procedural, object‑oriented, and generic programming. First standardized in 1998 (ISO/IEC 14882:1998), it has evolved through C++11/14/17/20/23—each revision adding modern safety and expressiveness.

Note — Why choose C++? Portability, direct hardware control, expansive ecosystems (game dev, embedded, finance), and zero‑cost abstractions that scale from microcontrollers to supercomputers.

// Small example program
#include <iostream>

int main() {
    std::cout << "Hello, C++!" << '\n';
}

2 · Toolchain & Build Systems

2.1 Compilers

2.2 CMake (de facto meta‑build)

# Minimum viable CMakeLists.txt
cmake_minimum_required(VERSION 3.29)
project(hello LANGUAGES CXX)
add_executable(hello main.cpp)

CMake generates native project files (.ninja, Makefiles, Visual Studio). Pair it with conan or vcpkg for dependency management.

2.3 Modules (C++20)

Replaces the textual #include model with binary‑interface units—reducing compile times and ODR headaches.

// math.ixx — a module interface
export module math;
export int add(int a,int b){return a+b;}

3 · Language Basics

3.1 Fundamental Types

3.2 Control Flow

for (auto& v : values) { /* range‑based loop */ }
if (auto* p = std::get_if<int>(&variant); p) { /* C++17 init‑stmt */ }

3.3 Functions

Overloading, default args, inline, constexpr (compile‑time), and noexcept specifications.

constexpr int square(int x) noexcept { return x * x; }

4 · Classes & OOP

4.1 Declaring Classes

class Image {
    std::string path_;
public:
    explicit Image(std::string path);
    void load();                 // member function
};

4.2 RAII & The Rule of 0/3/5/7

4.3 Inheritance & Polymorphism

class Shape {
public:
    virtual double area() const = 0;   // pure‑virtual
    virtual ~Shape() = default;
};

class Circle : public Shape {
    double r_;
public:
    explicit Circle(double r):r_{r}{}
    double area() const override { return 3.14159*r_*r_; }
};

5 · Templates & Generic Programming

5.1 Function Templates

template<typename T>
T max(T a, T b){ return a > b ? a : b; }

5.2 Class Templates

template<typename T,size_t N>
class Array {
    T data[N];
public:
    T& operator[](size_t i){ return data[i]; }
    // ...
};

5.3 Concepts (C++20)

template<typename T>
concept Number = std::is_arithmetic_v<T>;

template<Number T>
T add(T a,T b){ return a+b; }

6 · Standard Library (STL)

6.1 Containers

6.2 Algorithms

#include <algorithm>
std::ranges::sort(vec);          // C++20 ranges
auto pos = std::ranges::find(vec, 42);

6.3 Utilities

7 · Memory Management

7.1 Smart Pointers

auto file = std::make_unique<FILE, decltype(&fclose)>(fopen(path,"r"), &fclose);

Prefer make_unique / make_shared. Avoid naked new/delete except in low‑level libraries.

7.2 Allocators & pmr

Polymorphic Memory Resource (<memory_resource>) decouples containers from allocation strategy—great for arenas or embedded systems.

8 · Concurrency & Parallelism

8.1 Threads & Futures

#include <thread>
std::thread t([]{ heavy_work(); });
t.join();

8.2 Coroutines (C++20)

task<void> download() {
    co_await network;
    co_return;
}

8.3 Parallel Algorithms (C++17)

#include <execution>
std::sort(std::execution::par, vec.begin(), vec.end());

9 · Advanced Techniques

9.1 Compile‑Time Metaprogramming

template<size_t N> struct fib { static constexpr size_t value = fib<N-1>::value + fib<N-2>::value; };
template<> struct fib<0>{ static constexpr size_t value = 0; };
template<> struct fib<1>{ static constexpr size_t value = 1; };
static_assert(fib<10>::value == 55);

9.2 Reflection (C++26 draft)

Static reflection enables compile‑time introspection of named declarations.

9.3 Pattern Matching (under discussion)

match (v) {
    case 0:   std::println("zero"); break;
    case int i if (i > 10): std::println("large"); break;
}

10 · Debugging & Tooling

11 · Ecosystem & Package Managers

Binary package managers simplify dependency hell: vcpkg (Microsoft), conan (JFrog), hunter. Integrate with CMake via find_package() or toolchain files.

Note — Cross‑Compiling: CMake toolchain files let you target ARM, WebAssembly (emscripten), or embedded RTOS with one source tree.

12 · Best Practices

13 · Further Reading & Learning Path