C++C++

Learn C++ – all lessons

18 lessons from beginner to advanced, building on each other and with code examples.

Beginner
1

Hello World, main and #include

Structure of a C++ program, output with std::cout and the path from source code to program.

2

Variables, Types and const

Basic types, type inference with auto, safe initialization and constants.

3

Conditions: if, switch and Operators

Making decisions with if/else, switch, logical operators and the ternary operator.

4

Loops: for, range-for and while

Repeating code – over numbers and containers, with break and continue.

5

Functions, Overloading and Declarations

Defining functions, default arguments, overloading and multiple return values.

6

References, Pointers and const Correctness

Passing by value, by reference and by const reference, plus the basics of pointers.

7

std::string and std::vector

The two most important standard types: text and dynamic arrays.

Intermediate
8

Input, Files and Streams

Reading from the console, writing and reading files, splitting text with stringstream.

9

Classes, Constructors and Destructors

Your own types with data and behavior – including const methods and operators.

10

Inheritance, virtual and Polymorphism

Base classes, virtual methods, abstract classes and the slicing trap.

11

RAII and Smart Pointers

Managing resources safely with unique_ptr, shared_ptr and weak_ptr – without new and delete.

12

STL: Containers, Algorithms and Lambdas

map, set, sort, find, transform and lambdas – the toolbox of the standard library.

13

Error Handling: Exceptions and optional

try/catch, custom exception classes, noexcept and alternatives to exceptions.

Advanced
14

Templates and Generic Programming

Function and class templates, variadic templates and fold expressions.

15

Move Semantics and the Rule of Zero/Five

Moving resources instead of copying, rvalue references and perfect forwarding.

16

Ranges and Concepts (C++20)

Readable data pipelines with views and templates with clear requirements.

17

Undefined Behavior and Typical Pitfalls

Dangling references, iterator invalidation, overflows – and how sanitizers find them.

18

Modern C++: optional, variant, string_view and constexpr

Expressive building blocks from C++17/20 for safer and faster code.