free · open · no prior experience needed
Learn C++ the way it actually works.
A growing library of tutorials and references in modern C++, from your first program to templates, move semantics, and smart pointers.
The curriculum
All C++ articles
/
- 01 Declaring and Initializing Variables →
- 02 Integer Types →
- 03 Floating-Point Types →
- 04 Characters and Boolean Values →
- 05 Signed and Unsigned Types →
- 06 Fixed-Width Integer Types →
- 07 Constants with const and constexpr →
- 08 Type Inference with auto →
- 09 Variable Scope and Shadowing →
- 10 Storage Duration and Variable Lifetime →
- 11 Local and Global Variables →
- 12 std::size_t →
- 13 The sizeof Operator →
- 14 decltype →
- 01 Conditions with if, else if, and else →
- 02 The switch Statement →
- 03 while Loops →
- 04 do-while Loops →
- 05 for Loops →
- 06 break and continue →
- 07 Nested Loops →
- 08 Range-Based for Loops →
- 09 Common Loop Errors →
- 01 C-Style Arrays →
- 02 Array Bounds and Common Indexing Errors →
- 03 Looping Through Arrays →
- 04 Searching, Counting, and Updating Array Values →
- 05 Partially Filled Arrays and Tracking Used Elements →
- 06 Multidimensional Arrays →
- 07 Working with std::array and Comparing It with C-Style Arrays →
- 08 Arrays of std::string and Other Objects →
- 01 Introduction to STL Containers →
- 02 std::vector →
- 03 Vector Size, Capacity, and Reallocation →
- 04 std::deque →
- 05 std::list and std::forward_list →
- 06 std::set and std::unordered_set →
- 07 std::map and std::unordered_map →
- 08 std::stack, std::queue, and std::priority_queue →
- 09 Choosing the Correct Container →
- 10 Iterator and Reference Invalidation →
- 01 Lvalue References →
- 02 Passing by Reference →
- 03 Const References →
- 04 Returning by Reference →
- 05 Dangling References →
- 06 Rvalue References →
- 07 Temporary Objects →
- 01 Memory Addresses and Pointers →
- 02 Address-of and Dereference Operators →
- 03 Null Pointers and nullptr →
- 04 Passing Pointers to Functions →
- 05 Pointers and Arrays →
- 06 Passing Arrays to Functions and Understanding Array Decay →
- 07 Pointer Arithmetic →
- 08 Const Pointers and Pointers to Const →
- 09 const_cast and Const-Correctness →
- 10 Double Pointers (Pointers To Pointers) →
- 11 Void Pointers →
- 12 Function Pointers →
- 13 Dangling and Uninitialized Pointers →
- 14 Pointers Versus References →
- 01 Defining a Class →
- 02 Creating and Using Objects →
- 03 Public, Private, and Protected Access →
- 04 Declaring and Calling Member Functions →
- 05 Defining Member Functions Outside a Class (scope resolution operator) →
- 06 Encapsulation →
- 07 Constructors →
- 08 Destructors →
- 09 Explicit and Converting Constructors →
- 10 Constructor Initialization Lists →
- 11 Object Lifetime →
- 12 The this Pointer →
- 13 Const Member Functions →
- 14 Static Members →
- 15 Friend Functions and Classes →
- 16 Struct Versus Class →
- 01 Copy Constructors →
- 02 Copy Assignment Operators →
- 03 Shallow and Deep Copying →
- 04 The Rule of Three →
- 05 Move Constructors →
- 06 Move Assignment Operators →
- 07 std::move →
- 08 The Rule of Five →
- 09 The Rule of Zero →
- 10 Copy Elision and Return Value Optimization →
- 11 Deleted and Defaulted Functions →
- 01 Introduction to Operator Overloading →
- 02 Arithmetic and Comparison Operators →
- 03 Assignment Operators →
- 04 Stream Input and Output Operators →
- 05 Subscript and Function Call Operators →
- 06 Conversion Operators →
- 07 The Three-Way Comparison Operator →
- 08 When Operator Overloading Should Be Avoided →
- 01 Base and Derived Classes →
- 02 Constructor and Destructor Order →
- 03 Virtual Functions and Runtime Polymorphism →
- 04 Function Overriding with override and final →
- 05 Virtual Destructors →
- 06 Abstract Classes and Pure Virtual Functions →
- 07 Object Slicing →
- 08 Multiple and Virtual Inheritance →
- 09 dynamic_cast →
- 10 Composition Versus Inheritance →
- 01 What Is a Smart Pointer? Lesson on std::unique_ptr and std::make_unique →
- 02 Moving and Passing Unique Ownership →
- 03 Shared Ownership with std::shared_ptr and std::make_shared →
- 04 Using std::weak_ptr to Prevent Reference Cycles →
- 05 Custom Deleters →
- 06 Choosing the Correct Smart Pointer →
- 07 Raw Pointers as Non-Owning References →
- 01 Iterator Basics, begin(), and end() →
- 02 Iterator Categories, Const Iterators, and Reverse Iterators →
- 03 Searching with Standard Algorithms →
- 04 Sorting and Comparing Elements →
- 05 Copying, Moving, and Transforming Elements →
- 06 Removing Elements and the Erase-Remove Idiom →
- 07 Numeric Algorithms →
- 08 Introduction to std::span →
- 09 Introduction to C++ Ranges →
- 10 Filtering and Transforming with Views →
- 11 Algorithms Versus Manual Loops →
- 01 Function Templates →
- 02 Class Templates →
- 03 Template Argument Deduction →
- 04 Non-Type Template Parameters →
- 05 Template Specialization →
- 06 Variadic Templates →
- 07 Parameter Packs and Fold Expressions →
- 08 Type Traits →
- 09 SFINAE →
- 10 Perfect Forwarding with Forwarding References and std::forward →
- 11 Common Template Compilation Errors →
- 01 Assertions →
- 02 Throwing and Catching Exceptions →
- 03 Standard Exception Types →
- 04 Custom Exceptions →
- 05 Stack Unwinding →
- 06 Exception Safety →
- 07 The noexcept Keyword →
- 08 Error Codes →
- 09 std::optional →
- 10 std::expected →
- 11 Choosing Between Exceptions and Error Values →
- 01 std::pair and std::tuple →
- 02 Structured Bindings →
- 03 std::variant and std::visit →
- 04 std::any →
- 05 std::bitset →
- 06 std::reference_wrapper →
- 07 std::initializer_list →
- 01 std::memcpy and std::bit_cast →
- 02 Object Size, Alignment, and Padding →
- 03 reinterpret_cast and Low-Level Pointer Conversions →
- 04 Object and Byte Representation →
- 05 Endianness →
- 06 Strict Aliasing →
- 07 Placement new →
- 08 Constructing and Destroying Objects in Raw Storage →
- 09 Manual Object Lifetime →
- 10 Transparent Replacement and std::launder →
- 11 Cache Locality →
- 12 Custom Allocators →
- 13 Polymorphic Memory Resources →
- 01 Creating Threads with std::thread →
- 02 Joining and Detaching Threads →
- 03 Passing Data to Threads →
- 04 Race Conditions and Data Races →
- 05 Protecting Data with std::mutex →
- 06 std::lock_guard, std::unique_lock, and std::scoped_lock →
- 07 Deadlocks and How to Avoid Them →
- 08 Condition Variables →
- 09 Producer-Consumer Queues →
- 10 Futures, Promises, and std::async →
- 11 Thread-Local Storage →
- 12 std::jthread and Stop Tokens →
- 13 Building a Basic Thread Pool →
- 01 Atomic Variables →
- 02 Atomic Loads and Stores →
- 03 Compare-and-Exchange →
- 04 Memory Ordering →
- 05 Acquire and Release Semantics →
- 06 Sequential Consistency →
- 07 Lock-Free Programming →
- 08 False Sharing →
- 09 When Atomics Should Be Avoided →