C++ Tutorial with Examples.
C++ tutorial with examples: high-performance C++ for game engines, trading systems, embedded software and compute-intensive applications.
Beginner
Start here — no prior experience needed
Introduction to C++
What C++ is, how it differs from C, and why it powers games, trading and browsers — with RAII, classes and C++20 ranges shown compiling and running.
Setting Up C++ Development Environment
Install GCC or Clang, configure CMake, set up VS Code, and compile your first C++ program with modern standards.
Variables and Type System in C++
C++ variables with real compiler output: brace initialization and narrowing, auto, decltype, constexpr, references vs pointers, and structured bindings.
Data Types in C++
C++ data types run for real: sizes, overflow and float precision, fixed-width ints, std::string and string_view, std::array, vector growth and enum class.
Control Flow in C++
C++ control flow with real output: if with initializers, switch and [[fallthrough]], loops over stdin, if constexpr, break/continue, and std::optional.
Functions in C++
C++ functions with real g++ output: declarations across files, overload surprises, default arguments, constexpr/consteval, passing and templates.
Intermediate
For developers with core concepts down
Operators and Operator Overloading in C++
C++ operators run for real: integer division, short-circuiting, bit flags, overloading for a vector type, and the C++20 spaceship operator's categories.
Classes and Object-Oriented Programming in C++
C++ classes run for real: initializer-list order, const and mutable, a double free from a shallow copy, the Rule of Five logged, and the Rule of Zero.
Inheritance and Polymorphism in C++
Understand virtual functions, vtable mechanics, pure virtual functions, abstract classes, and multiple inheritance.
STL Containers in C++
Choose the right STL container with real output: vector growth, emplace vs push_back, deque, list, map's [] trap, hashing, sets, adapters, and a timing.
STL Algorithms in C++
STL algorithms run for real: sort and stable_sort, binary search, accumulate's init trap, erase-remove, ranges projections, lazy views and a parallel sort.
Smart Pointers in C++
unique_ptr, shared_ptr and weak_ptr run for real: a leak LeakSanitizer catches, reference counts, a shared_ptr cycle that never frees, and custom deleters.
Lambdas and Functional Programming in C++
C++ lambdas run for real: closure sizes, capture timing, mutable, a dangling capture caught by ASan, generic lambdas, std::function, recursion, [*this].
Error Handling in C++
Handle C++ errors with exceptions, noexcept, RAII, std::error_code and C++23 std::expected, each shown as a runnable program with real GCC 14 output.
File I/O in C++
C++ file I/O run for real: fstream open modes and silent failures, line/word/whole-file reads, CSV parsing, binary records, and std::filesystem.
C++ Interview Preparation: Top 35 Questions
Master the most common C++ interview questions with clear explanations and code examples.
Static Members in C++
Learn static data members and static member functions in C++ — shared per-class state, instance counters, and factory functions that run without an object.
Advanced
Production-grade patterns for experienced engineers
Templates in C++
C++ templates with real compiler output: function and class templates, specialization, type traits, SFINAE vs concept errors and compile-time recursion.
Move Semantics and Perfect Forwarding in C++
Move semantics run for real: value categories, what std::move does to a string, copy vs move timed, copy elision, pessimizing moves, and std::forward.
Memory Management in C++
Learn stack vs heap, RAII, new/delete pitfalls, struct padding, placement new and arenas, and catch memory bugs with Valgrind and AddressSanitizer.
Concurrency in C++
C++ threads run for real: joining, a data race ThreadSanitizer catches, mutex vs atomic costs, condition variables, futures, jthread, false sharing.
Design Patterns in C++
C++ design patterns run for real: CRTP, mixins, policy-based design, a PIMPL build and its destructor trap, Observer, Factory, thread-safe Singleton.
Performance Optimization in C++
C++ performance measured on real hardware: AoS vs SoA, traversal order, branch misprediction, -O levels and -Ofast, gprof, AVX2, avoiding copies.
Modern C++: C++17, C++20, and C++23 Features
C++17, C++20 and C++23 features run on GCC 13 and Clang 18: variant, concepts, std::format, span, jthread, coroutines, std::expected, deducing this.