Skip to content
Shafin Chowdhury

C++ Roadmap: Learn C++ Step by Step

A map of what to learn in C++, in what order, and how the pieces connect. Start at Stage 1 at the top, work down through the core concepts, then branch out into the areas you want to go deeper in.

Interactive roadmap

  1. Stage 8 · parallel branch, any order

    Competitive Programming

    Problem-solving techniques that turn slow brute force into fast solutions, for contests and coding interviews.

    6 topics

    Stage 9 · parallel branch, any order

    Practical Development

    Tools and habits for real projects. You can start these any time after the fundamentals.

    8 topics

  2. Goal

    A confident C++ developer

    Strong fundamentals, plus depth in the areas that matter to you.

Every topic, stage by stage

The same roadmap as a reading list. Each topic says what to learn first, what it unlocks, and where to read more.

Stage 1: Getting Started

Install the tools and run your first program.

What Is C++?

A compiled, general-purpose language that gives you direct control over memory and performance. It powers game engines, browsers, databases and embedded devices.

After this: Explain what C++ is used for and how it differs from Python or Java.

References:

Installing a Compiler

A compiler (GCC, Clang or MSVC) turns your C++ source code into a program your computer can run.

After this: Install a compiler and check its version from the terminal.

Learn first:

Setting Up an Editor or IDE

An editor such as VS Code, or an IDE such as Visual Studio or CLion, gives you highlighting, error hints and one-click builds.

After this: Write, build and run a file from your editor.

Learn first:
References:

↑ Back to Stage 1 in the roadmap

Stage 2: Programming Fundamentals

The building blocks every C++ program is made of.

Type Conversion

C++ converts some types automatically (implicit conversion); static_cast converts explicitly and makes your intent clear.

After this: Avoid surprises like integer division and use static_cast when needed.

Learn first:

Functions

Functions package reusable logic with parameters and a return value; declarations and definitions can live apart.

After this: Split a program into small, testable functions.

Learn first:

↑ Back to Stage 2 in the roadmap

Stage 3: Core C++ Concepts

How C++ works with memory: pointers, references and the heap.

Dynamic Memory Allocation

new and delete (and C's malloc and free) request memory at run time, for sizes you don't know in advance.

After this: Allocate and free memory correctly and spot memory leaks.

Type Aliases (typedef and using)

typedef and the modern using syntax give an existing type a shorter or clearer name.

After this: Read and write aliases such as using Score = long long;.

Function Pointers

A function pointer stores the address of a function, so you can pass behaviour around, for example as a callback.

After this: Pass a function to another function, such as a custom comparison.

Learn first:

↑ Back to Stage 3 in the roadmap

Stage 4: Object-Oriented Programming

Model programs as objects with classes.

Operator Overloading

Give operators like +, == and << meaning for your own types, so they read like built-in ones.

After this: Overload common operators while following their usual meaning.

References:

Struct vs Class

The only language difference is default access: struct members are public, class members are private. By convention, struct is for plain data and class for types with rules to protect.

After this: Choose between struct and class on purpose.

Virtual Destructors

Deleting a derived object through a base-class pointer only runs the derived destructor if the base destructor is virtual.

After this: Write base classes that clean up derived objects correctly.

Learn first:

↑ Back to Stage 4 in the roadmap

Stage 5: Standard Template Library

Ready-made containers and algorithms you will use every day. Learn it alongside OOP.

std::pair

Holds two values together (.first and .second). It's often returned from functions and stored in maps.

After this: Group two related values without writing a struct.

Then try:
References:

std::map

Sorted key-value pairs with O(log n) lookup, insertion and removal.

After this: Count, group and look up data by key in sorted order.

Learn first:
Then try:
References:

std::unordered_map

A hash table: average O(1) lookup, with no ordering of keys.

After this: Choose between map and unordered_map for a task.

Learn first:
Then try:
References:

std::set

Stores unique values in sorted order.

After this: Remove duplicates and check membership quickly.

Learn first:
Then try:
References:

std::unordered_set

Unique values in a hash table: average O(1) membership checks, no order.

After this: Pick the right set for the job.

Learn first:
References:

std::deque

A double-ended queue: fast insertion and removal at both ends. std::stack and std::queue use it by default.

After this: Use a deque when you need both ends, such as for sliding windows.

Learn first:
Then try:
References:

Iterators

Objects that point into a container. begin() and end() connect containers to algorithms.

After this: Loop with iterators and understand why some operations make them invalid.

Learn first:
Then try:
References:

STL Algorithms

sort, find, count, binary_search, accumulate and more, ready-made and well tested.

After this: Replace hand-written loops with standard algorithms.

Learn first:
References:

std::priority_queue

A container adaptor that always hands you the largest element first, or the smallest with std::greater. It is a heap underneath.

After this: Repeatedly take the best item, as in Dijkstra's algorithm or task scheduling.

Learn first:
Then try:

std::tuple

Groups any number of values of different types. Structured bindings unpack it: auto [a, b, c] = t;

After this: Return several values from a function cleanly.

Learn first:

std::optional

Holds either a value or nothing, so a function can report "no result" without magic values like -1 (C++17).

After this: Return a value that might be missing, safely.

Then try:

std::variant

A type-safe union: it holds exactly one of several types, checked with std::visit or std::holds_alternative (C++17).

After this: Model a value that can be one of a few different types.

Learn first:

Numeric Algorithms

The <numeric> header provides std::accumulate, std::iota, std::partial_sum, std::gcd and more for working with sequences of numbers.

After this: Sum, fill and combine ranges of numbers without hand-written loops.

Learn first:
Then try:

↑ Back to Stage 5 in the roadmap

Stage 6: Data Structures & Algorithms

Solve problems efficiently and reason about performance.

Stacks

Implement a LIFO stack yourself with an array, a vector and a linked list, then solve classic stack problems.

After this: Build a stack from scratch and recognise stack-shaped problems.

Learn first:

Queues

Implement FIFO queues, including the circular queue, and use them in BFS-style problems.

After this: Build linear and circular queues and solve classic queue problems.

Learn first:

Binary Search Trees

A tree that keeps smaller keys on the left and larger on the right, which is how std::map stays sorted.

After this: Insert, search and delete in a BST.

Learn first:

Heaps

A tree stored in an array that always gives you the smallest or largest element. It's what std::priority_queue uses.

After this: Use priority_queue and explain heap insertion and removal.

Learn first:

Breadth-First Search (BFS)

Explores a graph level by level with a queue. It finds shortest paths when every edge has the same cost.

After this: Find shortest paths in unweighted graphs and grids.

Learn first:
References:

Depth-First Search (DFS)

Explores as deep as possible before backtracking, using recursion or a stack.

After this: Detect cycles and connected components, and do topological sorts.

Learn first:
References:

Greedy Algorithms

Make the best local choice at each step. It's fast, but only correct when the problem allows it.

After this: Recognise when greedy works and prove it on simple problems.

Learn first:

Dynamic Programming

Break a problem into overlapping subproblems and reuse their answers (memoization or tabulation).

After this: Turn a slow recursive solution into an efficient DP one.

Then try:

Hash Tables

A hash function maps keys to buckets for average O(1) lookup; collisions are handled by chaining or probing.

After this: Explain how unordered_map works and when it slows down.

Disjoint Set Union (DSU)

Tracks which elements belong to the same group, with near-constant-time union and find using path compression and union by size.

After this: Detect cycles and connected components quickly.

Learn first:
References:

Minimum Spanning Trees

Connect every node with the least total edge weight using Kruskal's algorithm (sorted edges plus DSU) or Prim's algorithm.

After this: Build the cheapest network that connects every point.

Segment Trees

A tree over an array that answers range queries (sum, min, max) and handles updates, each in O(log n).

After this: Answer many range queries on data that keeps changing.

Learn first:

Fenwick Trees

A compact array-based structure (binary indexed tree) for prefix sums with point updates, both in O(log n).

After this: Maintain running totals while values change.

↑ Back to Stage 6 in the roadmap

Stage 7: Modern & Advanced C++

Write safe, efficient, idiomatic modern C++.

Exception Handling

throw, try and catch report errors that can't be handled where they happen.

After this: Throw and catch exceptions and know when error codes are better.

Then try:
References:

Smart Pointers

unique_ptr and shared_ptr own heap memory and free it automatically, replacing most raw new and delete.

After this: Choose unique_ptr or shared_ptr, and stop writing delete by hand.

References:

File Handling

ifstream and ofstream read and write files with the same << and >> you use for cin and cout.

After this: Read input from a file and write results to one.

Learn first:

Multithreading

std::thread runs work in parallel; mutexes and atomics stop threads from corrupting shared data.

After this: Start threads safely and avoid data races.

Learn first:
References:

Advanced STL

priority_queue, custom comparators, emplace, iterator invalidation rules and choosing containers for performance.

After this: Use the STL confidently in larger programs.

constexpr

Marks values and functions that can be computed at compile time, so the work happens before the program runs.

After this: Move fixed calculations and lookup tables to compile time.

Learn first:

auto

Lets the compiler deduce a variable's type from its initializer, which keeps long iterator and lambda types readable.

After this: Use auto where it helps and spell out types where it hides intent.

Then try:
References:

decltype

Gives the declared type of an expression, useful in templates and in return types that depend on the arguments.

After this: Write a function whose return type depends on its parameters.

Learn first:
Then try:

Type Deduction

The rules the compiler uses to infer template arguments and auto types, including when references and const are kept or dropped.

After this: Predict what type auto or a template parameter will become.

Learn first:
Then try:

Concepts

Named requirements on template parameters (C++20) that give clear error messages and replace most enable_if tricks.

After this: Constrain a template so it only accepts suitable types.

Learn first:
Then try:

Ranges

C++20 algorithms that take whole containers, plus composable views like filter and transform joined with |.

After this: Write data pipelines without manual iterator pairs.

Undefined Behavior

Operations the standard gives no meaning to, such as out-of-bounds access or signed overflow. The program may seem to work, then fail anywhere.

After this: Recognise common undefined behavior and catch it with sanitizers.

Alignment

Each type must sit at an address that is a multiple of its alignment, so the compiler adds padding inside structs.

After this: Predict sizeof for a struct and reorder members to save memory.

↑ Back to Stage 7 in the roadmap

Stage 8: Competitive Programming

Problem-solving techniques that turn slow brute force into fast solutions, for contests and coding interviews.

Two Pointers

Move two indices through an array, often a sorted one, to find pairs or ranges in linear time.

After this: Solve pair-sum and merge-style problems in O(n).

Learn first:
Then try:

Binary Search on the Answer

When you can check whether a candidate answer works, and the check is monotonic, binary search over the possible answers.

After this: Turn optimisation problems into yes/no checks.

Learn first:

Bitmasking

Represent subsets as the bits of an integer to loop over every subset or run dynamic programming over them.

After this: Enumerate subsets and write bitmask DP for small inputs.

↑ Back to Stage 8 in the roadmap

Stage 9: Practical Development

Tools and habits for real projects. You can start these any time after the fundamentals.

Debugging

Use breakpoints, step through code and inspect variables with a debugger (gdb, lldb or your IDE) instead of guessing.

After this: Find a bug by stepping through code rather than adding prints.

Learn first:
Then try:

Testing

Small automated tests check that functions keep working as you change code.

After this: Write unit tests for your own functions.

Learn first:

Build Systems

How multi-file projects are compiled: headers, source files, object files, linking and libraries.

After this: Split a project into .h and .cpp files and build it.

CMake

The most common way to describe a C++ project's build so it works with any compiler and IDE.

After this: Write a CMakeLists.txt for a small project.

Learn first:
References:

Code Organization

Folders, headers, namespaces and modules that keep a growing project easy to navigate.

After this: Structure a project so others can find their way around.

Learn first:

Writing Maintainable Code

Clear names, small functions, consistent formatting and comments that explain why.

After this: Write code a teammate can read and change safely.

Learn first:
References:

Software Development Practices

Code review, pull requests, issue tracking and continuous integration: how teams ship software together.

After this: Work on a shared codebase the way professional teams do.

Learn first:

↑ Back to Stage 9 in the roadmap

Frequently asked questions

How long does it take to learn C++?

It depends on how much you practise. With regular practice, most beginners get comfortable with the first three stages in a few months. The later stages are something you keep improving at for years, usually while building real projects.

Do I need to learn C before C++?

No. C++ can be your first language. Learning C first teaches habits, like manual memory handling everywhere, that modern C++ replaces with safer tools such as std::string, std::vector and smart pointers.

Do I have to finish every stage?

No. Stages 1 to 5 are the foundation almost everyone needs. After that, the three branches can be learned in any order, and the right mix depends on your goal. Competitive programmers lean on data structures and algorithms, while backend and systems developers need more of the modern C++ and practical development branches.

Which compiler and editor should I use?

Any modern compiler works: GCC or Clang on Linux and macOS, or MSVC with Visual Studio on Windows. VS Code with the C++ extension is a popular free editor on every platform.

Where is my progress saved?

In your browser's local storage on this device. There is no account and nothing is sent to a server. Clearing your browser's site data, or using a different browser, starts you from zero.