Learnr

Learn C++

Write fast, modern C++ with classes, the STL and safe memory handling.

or browse all courses.

Free to start. Built from a single prompt. No credit card.

C++ extends C with classes, templates, references and a large standard library, letting you write high-level abstractions that still compile to very fast machine code. It powers game engines like Unreal, browsers, trading systems, robotics and many desktop applications. Modern C++ (C++11 and later) looks quite different from older code: you use std::vector instead of raw arrays, smart pointers instead of manual delete, and RAII to tie resource cleanup to object lifetime. Learnr builds a personalized C++ course from one prompt and teaches it through short interactive lessons that emphasize modern habits.

How to learn C++, step by step

  1. Set up a modern compiler and standard. Install g++ or clang++ and compile with -std=c++20 -Wall -Wextra, or use Visual Studio on Windows. Starting on a recent standard means you learn current idioms instead of habits from the 1990s.
  2. Learn references, const and value semantics. Understand passing by value, by reference and by const reference, and when each copies data. Getting this right early explains most performance and correctness questions in C++.
  3. Use the STL before raw arrays and new. Reach for std::vector, std::string, std::map and std::unordered_map first, and practice range-based for loops plus algorithms like std::sort and std::find. They are safer and usually as fast as hand-written code.
  4. Write classes and understand object lifetime. Write constructors, destructors and member functions, and watch when objects are created and destroyed by printing in each. This is the foundation for RAII, where cleanup happens automatically in the destructor.
  5. Manage memory with smart pointers. Use std::unique_ptr for single ownership and std::shared_ptr only when ownership is truly shared. Learn the rule of zero, and run AddressSanitizer to catch dangling pointers in practice code.
  6. Build a real project with CMake. Write a small game with a library like SFML or raylib, a command-line tool or a matrix library, using CMake to build it. Short Learnr sessions keep templates and STL details fresh between coding sessions.

What you'll learn

  • Write programs with classes, constructors, destructors and references
  • Use STL containers like vector, map and unordered_map with algorithms
  • Manage resources with RAII, unique_ptr and shared_ptr
  • Write generic code with function and class templates
  • Build a multi-file project with CMake and debug it

What's inside your C++ course

A sample path Learnr builds for C++. Your real course adapts to your goal and level.

  • 1. Compiling C++ and core syntax
  • 2. Functions, references and const
  • 3. Classes, constructors and object lifetime
  • 4. The STL: containers, iterators and algorithms
  • 5. Memory, RAII and smart pointers
  • 6. Templates, CMake and a complete project

How long does it take to learn C++?

Core syntax, classes and the main STL containers take about 2 to 4 months at 5 to 8 hours a week. Templates, move semantics and confident modern C++ take 6 to 12 months or more. C++ is large, and even experienced developers keep learning parts of it.

What you need before you start

No prior language is strictly needed, but C++ is a demanding first language. Some experience with any language, or with C, makes the learning curve much gentler.

Common mistakes to avoid

  • Learning from old tutorials that use raw new and delete everywhere. Prefer modern sources that teach containers and smart pointers first.
  • Passing large objects like vectors by value without meaning to, which copies them on every call. Pass by const reference unless you need a copy.
  • Trying to learn every feature at once. Focus on classes, the STL and RAII, then add templates and move semantics as projects require them.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn C++, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full C++ course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

C++ questions, answered

Is C++ good for game development?

Yes. Unreal Engine uses C++, and many studio engines are written in it because it gives fine control over performance and memory. Unity uses C# instead, which is a gentler start.

Do I need to learn C before C++?

No. You can start with C++ directly, and modern C++ discourages several C habits. Knowing C helps you understand pointers and low-level code you will meet in older projects.

What version of C++ should I learn?

Learn C++17 or C++20 features from the start, since compilers support them widely. Key modern features include auto, range-based for loops, smart pointers, lambdas and structured bindings.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn C++?

Start your free, personalized C++ course in seconds. .