C++ Programming

Learn C++ from your first cout to references, strings, vectors, the standard library, templates and error handling, with every variable and object on screen as your code runs.

Level
Beginner
Time
About 45 hours
Modules
4
Lessons
16
Exercises
48

C++ is the language behind game engines, browsers, databases and much of the world's fastest software. It gives you direct control over memory, along with powerful tools that take care of the details. This course starts from nothing, with no knowledge of C needed, and teaches modern habits from the beginning.

You begin with input, output and basic logic, then move on to the things that make everyday C++ productive: references, strings, vectors, maps and the standard algorithms. The last part covers templates, exceptions, files and the habits of modern C++. Every exercise is checked by running your code against hidden tests, and each reference solution also compiles and passes with the real g++ compiler.

What you will learn

  • Write correct C++ programs with functions, conditions and loops
  • Choose between passing by value and by reference
  • Store and process data with string, vector, map and set
  • Use the standard algorithms in place of hand-written loops
  • Write templates, handle errors and work with files

Skills you will gain

  • Writing modern, readable C++
  • Using the standard library effectively
  • Reasoning about copies, references and memory
  • Reading compiler errors
  • Handling errors and resources safely

Before you start

  • Basic computer skills: using a browser and typing
  • School-level arithmetic
  • No programming experience is needed

Where it is used

  • Game development and graphics
  • High-performance systems and trading software
  • Competitive programming
  • Embedded systems and robotics

Modules

Module 1: Foundations

The parts of a C++ program, the types of its values, reading and formatting data, and how programs choose and repeat.

  1. 1

    Your first C++ program

    The parts of a C++ program, printing with cout, reading with cin, and what namespaces are for.

  2. 2

    Variables and types in C++

    Store values in variables, choose among int, double, char, bool and string, use const and auto, and convert between types safely.

  3. 3

    Input and output in depth

    Read whole lines with getline, read until the input ends, and format output in columns with iomanip.

  4. 4

    Decisions and loops

    Choose with if and switch, repeat with for and while, and control a loop with break and continue.

Module practice and quiz →

Module 2: Functions and everyday data

Splitting programs into functions, passing data efficiently with references, and working with text, lists and memory.

  1. 1

    Functions in C++

    Write functions with parameters and return values, give parameters default values, and overload one name for different types.

  2. 2

    References Intermediate

    Give a variable a second name, let functions change their caller's variables, and pass large values without copying them.

  3. 3

    The string class

    Work with std::string: length, characters, joining, searching and cutting, and pulling words apart with string streams.

  4. 4

    Vectors

    Store lists that grow with std::vector: adding and removing items, looping safely, sorting, and two-dimensional tables.

  5. 5

    Pointers and memory Intermediate

    Addresses and pointers, nullptr, new and delete, and why modern C++ usually lets containers manage memory for you.

Module practice and quiz →

Module 3: Your own types and the standard library

Defining structs and classes, then using the containers and algorithms that make up the heart of everyday C++.

  1. 1

    Structs and your first class

    Group related data with struct, then protect it in a class with private members, a constructor and methods.

  2. 2

    Maps and sets

    Look values up by key with map, keep unique sorted values with set, and choose between ordered and unordered containers.

  3. 3

    Stacks, queues and pairs

    Choose the right container for the order you need: stack, queue, deque, priority_queue, and pair for two values together.

  4. 4

    Iterators and algorithms Intermediate

    Walk containers with iterators, and use the standard algorithms to sort, search, count and transform instead of writing loops by hand.

Module practice and quiz →

Module 4: Going further

Generic code with templates, reliable error handling and files, and the habits of modern C++.

  1. 1

    Templates Intermediate

    Write one function or class that works for many types, and see how the compiler generates the code for each.

  2. 2

    Exceptions and files Intermediate

    Report and handle errors with throw, try and catch, and read and write files with streams that close themselves.

  3. 3

    Modern C++ Intermediate

    The habits of current C++: auto and range-based for, enum class, objects that clean up after themselves, smart pointers and lambdas.

Module practice and quiz →

Projects

Final assessment →

What to learn next