← All tutorials

C++ Tutorial

Learn C++ from basics to OOP, the STL, smart pointers, move semantics, templates and modern concurrency. Each topic has code, key points and interview questions for placements and competitive coding.

27 topics · Beginner → Expert · concept, code, interview questions and a test in every topic

Your progress0%

Beginner lessons

0/3 · 0%
  1. 1Introduction & I/OFirst program, namespaces, cin/cout and fast I/O.
  2. 2Types, References & autoFundamental types, references, const and type inference.
  3. 3Functions, Overloading & LambdasDefault arguments, overloading, inline and lambda expressions.

Intermediate lessons

0/4 · 0%
  1. 4Classes, Constructors & DestructorsAccess specifiers, initialiser lists, this and static members.
  2. 5Copy Control: Rule of 3/5/0Copy constructor, assignment, deep vs shallow copy.
  3. 6Inheritance & Virtual FunctionsRuntime polymorphism, vtables, abstract classes and override.
  4. 7STL Containersvector, map, unordered_map, set, deque, stack, queue, priority_queue.

Advanced lessons

0/4 · 0%
  1. 8Iterators & STL Algorithmssort, binary search, accumulate, transform and iterator invalidation.
  2. 9Functions Reference: STL & stringstd::string methods, container member functions and <algorithm> functions.
  3. 10Operator OverloadingCustom operators, comparisons and the spaceship operator.
  4. 11RAII & Smart Pointersunique_ptr, shared_ptr, weak_ptr and automatic cleanup.

Expert lessons

0/4 · 0%
  1. 12Move Semantics & Rvalue Referenceslvalues vs rvalues, std::move, perfect forwarding.
  2. 13Templates & ConceptsFunction/class templates, specialisation and C++20 concepts.
  3. 14Concurrency: Threads, Mutex & Atomicsstd::thread, jthread, mutex, lock_guard, atomic and async.
  4. 15Modern C++ Features (17/20/23)Structured bindings, optional, variant, ranges and more.

Interview preparation

Module — Core Technical Interview Q&A (Top Questions & Answers)

6 questions · 0 completed · 0%

Beginner: 1 · Freshers · 0 yearsBasic: 1 · Entry level · 0–1 yearsIntermediate: 1 · Junior · 1–3 yearsAdvanced: 1 · Mid-level · 3–5 yearsExpert: 1 · Senior · 5–8 yearsArchitect / Specialist: 1 · Specialist · 8–10+ years
  1. Beginner · Fundamentals

    How do references differ from pointers in an API?

    A reference expresses an alias to an existing object and must be initialized. A pointer is a value that may be null and can be reseated, so it can express optional access.

  2. Basic · Resource ownership

    Why does RAII clean up correctly during exceptions?

    An automatic object is destroyed when its scope ends, including stack unwinding after an exception. A resource-owning object can therefore release its resource in its destructor.

  3. Intermediate · Modern C++

    Why doesn’t std::move necessarily move an object?

    std::move casts an expression to an rvalue reference category; the receiving constructor or assignment operator decides whether a move actually occurs.

  4. Advanced · Containers

    How can vector growth invalidate a perfectly valid pointer?

    When vector capacity is exhausted, it allocates a new buffer and moves or copies elements there. References, pointers and iterators into the old buffer become invalid.

  5. Expert · Concurrency

    Why is a C++ data race more serious than a lost update?

    Concurrent conflicting accesses to the same memory, at least one a write, without required synchronization create a data race and undefined behavior. It is not merely an unpredictable final count.

  6. Architect / Specialist · Architecture

    How would you design a resource-owning container with strong exception safety?

    Define the ownership invariant first: each live allocation has one owner, size counts initialized elements, and every observable state is valid.

Module — Coding Interview Problems & Solutions (Hands-on)

6 questions · 0 completed · 0%

Beginner: 1 · Freshers · 0 yearsBasic: 1 · Entry level · 0–1 yearsIntermediate: 1 · Junior · 1–3 yearsAdvanced: 1 · Mid-level · 3–5 yearsExpert: 1 · Senior · 5–8 yearsArchitect / Specialist: 1 · Specialist · 8–10+ years
  1. Beginner · Strings

    Check a byte-string palindrome without a reversed copy

    Return whether a std::string reads identically in both byte directions.

  2. Basic · Binary search

    Return the first matching index in a sorted vector

    Return the first index equal to target or -1 in a nondecreasing integer vector.

  3. Intermediate · Hashing

    Find distinct indices with a target sum using a hash map

    Return the first pair encountered by a left-to-right scan, or {-1,-1}.

  4. Advanced · Data structures

    Implement an LRU cache with stable list iterators

    Implement integer-key get/put with capacity-limited least-recent eviction.

  5. Expert · Resource ownership

    Implement a minimal move-only owner for one int

    Create an owning wrapper that deletes one int, disallows copying and transfers ownership on moves.

  6. Architect / Specialist · Exception-safe design

    Append a bounded batch with the strong exception guarantee

    Append all batch values or leave the original buffer unchanged on capacity or allocation failure.

A–Z index

Can't find a C++ topic you need for exams or placements? Request it and we'll add it.