Learn C++ from Scratch
The complete beginner's path through C++. Each guide builds on the last — follow them in order and you'll go from zero to writing real programs with confidence.
Stage 1: Getting Started
Install a compiler, write your first program, and understand what C++ is actually used for.
- 1 What Is C++ Used For? Practical Applications Explained
Understand why C++ matters — where it's used in the real world before you write a single line.
- 2 How to Start Learning C++: A Beginner's Setup Guide
Install a compiler, pick an IDE, and get your environment ready to code.
- 3 C++ Hello World Explained Line by Line
Your first program — every line explained so nothing is mysterious.
- 4 C++ Learning Roadmap: What to Learn and In What Order
The full picture — a structured path from beginner to advanced topics.
- 5 C++ endl vs \n: Difference and Which to Use
When to use std::endl versus the \n character, and why endl can slow down loops.
- 6 C++ getline: Read a Full Line of Input With Spaces
Read strings with spaces and fix the classic getline-after-cin empty-input bug.
Stage 2: Core Language Fundamentals
The building blocks every C++ program uses — master these before anything else.
- 5 C++ Variables and Data Types: A Complete Beginner's Guide
int, double, char, string, bool — the types you'll use in every program.
- 6 C++ User Input with cin: Reading from the Keyboard
Make your programs interactive — cin, getline, and handling different input types.
- 7 C++ Conditionals Tutorial: if, else, and switch Explained
Make your program make decisions — if/else, else-if chains, switch, and the ternary operator.
- 8 C++ Enum Tutorial: Named Constants and enum class Explained
Replace magic numbers with readable named values — enum, enum class, and when to use each.
- 9 C++ Loops Tutorial: for, while, and do-while Explained
Repeat code efficiently — for loops, while loops, break, continue, and the range-based for loop.
- 10 C++ Functions Tutorial: How to Write and Use Functions
Organise code into reusable blocks — parameters, return types, overloading, and scope.
- 11 C++ Recursion Tutorial: How Recursive Functions Work
Functions that call themselves — base cases, the call stack, factorial, Fibonacci, and binary search.
- 12 C++ Arrays Tutorial: Store and Access Multiple Values
Fixed-size collections — declaration, initialization, iteration, and multi-dimensional arrays.
- 13 C++ Error Messages Explained: What They Mean and How to Fix Them
Decode the compiler — undeclared identifier, undefined reference, no matching function, and more.
- 14 C++ 2D Arrays: How to Declare, Initialize, and Iterate
Grids, matrices, and tables — declare, initialize, iterate, and pass 2D arrays to functions.
- 15 C++ Scope Resolution Operator (::) Explained for Beginners
Understand what :: means — namespaces, class methods, static members, and why you write std::cout.
- 16 C++ Function Overloading: Same Name, Different Parameters Explained
Define multiple functions with the same name — the compiler picks the right one based on the arguments you pass.
- 17 C++ Default Arguments: How to Give Function Parameters Default Values
Make function parameters optional with fallback values — cleaner APIs with less repetition.
- 18 C++ Bitwise Operators Explained: AND, OR, XOR, Shift, and NOT
Manipulate integers at the bit level — &, |, ^, ~, <<, >> with practical examples and flag patterns.
- 19 How to Return Multiple Values from a C++ Function: 5 Practical Methods
Structs, pairs, tuples, and output parameters — every clean way to get more than one value back from a function.
- 20 C++ Fibonacci Program: Iterative, Recursive, and Memoized Approaches
Implement the Fibonacci sequence three ways — practice loops, recursion, and dynamic programming in one exercise.
- 21 How to Swap Two Numbers in C++: 4 Methods
Temp variable, std::swap, references, and the no-temp trick — with trade-offs.
- 22 C++ Prime Number Program: Check and Print Primes
Check if a number is prime and print primes up to n with the square root method.
- 23 C++ Factorial Program: Loop and Recursion Methods
Compute factorials two ways, compare loop vs recursion, and avoid integer overflow.
- 24 C++ Palindrome Program: Strings and Numbers
Two-pointer string checks and digit-reversal number checks, with common pitfalls.
Stage 3: Pointers and Memory
What makes C++ different from every other language — and what makes it powerful.
- 14 How to Use Pointers in C++: A Complete Beginner's Guide
The mental model that makes pointers click — addresses, dereferencing, null pointers, and references.
- 15 Memory Management in C++: Heap vs Stack, new/delete, and Memory Leaks
How the stack and heap work, when to use new/delete, and how to prevent memory leaks.
- 16 Smart Pointers in Modern C++: unique_ptr, shared_ptr, and weak_ptr
The modern replacement for raw pointers — automatic memory management without garbage collection.
- 17 C++ nullptr vs NULL: What's the Difference
Why nullptr is type-safe, the overload bug NULL causes, and when to use each.
Stage 4: Object-Oriented Programming
Model real-world problems with classes, inheritance, and polymorphism.
- 17 C++ Classes and Objects: A Beginner's Guide to OOP
Define your own types — constructors, member variables, methods, and access control.
- 18 OOP in C++: Inheritance, Encapsulation, and Polymorphism Explained
The four pillars of object-oriented programming applied to real C++ code.
- 19 C++ Operator Overloading: A Beginner's Guide
Define what +, ==, <<, and other operators do for your own classes — with practical examples.
- 20 Virtual Functions and Polymorphism in C++ Explained
Runtime polymorphism — how virtual functions and the vtable actually work.
- 21 C++ Copy Constructor: Deep Copy vs Shallow Copy Explained
When the default copy breaks — deep vs shallow copy, the Rule of Three, and safe resource management.
- 22 C++ Constructor Initializer Lists Explained for Beginners
Initialize members efficiently — syntax, why it's faster than body assignment, and when it's required.
- 23 C++ Inheritance Explained: Base Classes, Derived Classes, and How It Works
Reuse and extend existing classes — base and derived classes, access specifiers, and constructor chaining.
- 24 C++ Abstract Classes Explained: Pure Virtual Functions and Interfaces
Define contracts that subclasses must fulfill — pure virtual functions, abstract base classes, and C++ interfaces.
Stage 5: The Standard Library
C++'s built-in containers and algorithms — the tools you'll use in every real project.
- 21 C++ Vector Tutorial: The Complete Guide to std::vector
The most-used container in C++ — dynamic arrays, iteration, sorting, and memory management.
- 22 C++ map and unordered_map Tutorial: Key-Value Storage Explained
Look up values by key in O(log n) or O(1) — when to use each and how to use both.
- 23 C++ String Handling: std::string, string_view, and Performance Tips
Everything about strings — methods, concatenation, searching, and modern string_view.
- 24 C++ int to string Conversion: Every Method Explained
Convert between numbers and strings — to_string, stringstream, stoi, and stod with examples.
- 25 C++ Random Numbers: rand(), srand(), and the Modern <random> Library
Generate random numbers the right way — from rand() basics to the modern mt19937 engine.
- 26 C++ STL Containers Explained: Choosing the Right Container
vector, list, deque, set, map, stack, queue — which to pick and why.
- 27 How to Convert String to int in C++: stoi, atoi, and stringstream
The complement to to_string — safely converting user input and file data back to integers.
- 28 C++ std::set Tutorial: Sorted Unique Collections for Beginners
Automatic deduplication and sorting in one container — insert, find, erase, and iteration.
- 29 C++ std::pair Explained: Store Two Values Together for Beginners
Group any two values without a struct — first, second, make_pair, and how maps use pair internally.
- 30 C++ Queue and Stack Tutorial: FIFO and LIFO Containers Explained
Two fundamental data structures — std::stack for LIFO and std::queue for FIFO with practical examples.
- 31 C++ Math Functions: Using the cmath Library for Beginners
sqrt, pow, abs, floor, ceil, round, and trig functions — everything in one place with working examples.
- 32 C++ Output Formatting with iomanip: setw, setprecision, and More
Print aligned tables and precise decimals — control column width, alignment, fill characters, and number bases.
- 33 C++ 2D Vector: How to Create and Use a Vector of Vectors
Build grids and matrices that resize at runtime — the flexible alternative to fixed 2D arrays.
- 34 C++ std::sort Explained: How to Sort Vectors and Arrays for Beginners
Sort any container in one line — ascending, descending, custom comparators, and sorting objects by field.
- 35 C++ stringstream Tutorial: Parse and Build Strings Like a Pro
Treat strings as streams — convert types, split words, and build formatted output using the sstream header.
- 36 C++ Iterators Explained: How to Traverse STL Containers for Beginners
Master begin(), end(), reverse iterators, and how to erase elements safely — the foundation of STL algorithms.
Stage 6: Modern C++ Features
C++11 and beyond — the features that make modern C++ fast, safe, and expressive.
- 27 C++ Lambda Functions Explained: Closures, Captures, and std::function
Inline anonymous functions — syntax, capture lists, using lambdas with STL algorithms.
- 28 C++ Move Semantics Explained: rvalue References, std::move, and Performance
Transfer ownership instead of copying — one of the biggest performance wins in modern C++.
- 29 C++ Templates Explained: Write Code That Works with Any Type
Generic programming — write a function or class once, use it with any type.
- 30 Exception Handling in C++: try, catch, and throw Explained
Handle errors gracefully — exceptions, custom exception classes, and RAII.
- 31 C++ Concurrency Tutorial: Threads, Mutex, and Thread Safety Explained
Write programs that run on multiple CPU cores — std::thread, mutex, lock_guard, and atomics.
- 32 C++ auto Keyword Explained: Type Deduction for Beginners
Let the compiler deduce your types — when and how to use auto cleanly in modern C++.
- 33 C++ Type Casting Explained: static_cast, dynamic_cast, and reinterpret_cast Explained
Use the right cast for the job — static_cast, dynamic_cast, const_cast, and reinterpret_cast explained with examples.
- 34 C++ Range-Based For Loop: The Modern Way to Loop
Cleaner iteration over containers with auto and references, plus its limitations.