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
Beginner lessons
0/3 · 0%
Intermediate lessons
0/4 · 0%
- 4Classes, Constructors & DestructorsAccess specifiers, initialiser lists, this and static members.
- 5Copy Control: Rule of 3/5/0Copy constructor, assignment, deep vs shallow copy.
- 6Inheritance & Virtual FunctionsRuntime polymorphism, vtables, abstract classes and override.
- 7STL Containersvector, map, unordered_map, set, deque, stack, queue, priority_queue.
Advanced lessons
0/4 · 0%
- 8Iterators & STL Algorithmssort, binary search, accumulate, transform and iterator invalidation.
- 9Functions Reference: STL & stringstd::string methods, container member functions and <algorithm> functions.
- 10Operator OverloadingCustom operators, comparisons and the spaceship operator.
- 11RAII & Smart Pointersunique_ptr, shared_ptr, weak_ptr and automatic cleanup.
Expert lessons
0/4 · 0%
- 12Move Semantics & Rvalue Referenceslvalues vs rvalues, std::move, perfect forwarding.
- 13Templates & ConceptsFunction/class templates, specialisation and C++20 concepts.
- 14Concurrency: Threads, Mutex & Atomicsstd::thread, jthread, mutex, lock_guard, atomic and async.
- 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%
Module — Core Technical Interview Q&A (Top Questions & Answers)
6 questions · 0 completed · 0%
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.
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.
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.
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.
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.
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%
Module — Coding Interview Problems & Solutions (Hands-on)
6 questions · 0 completed · 0%
Beginner · Strings
Check a byte-string palindrome without a reversed copy
Return whether a std::string reads identically in both byte directions.
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.
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}.
Advanced · Data structures
Implement an LRU cache with stable list iterators
Implement integer-key get/put with capacity-limited least-recent eviction.
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.
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
- Append a bounded batch with the strong exception guarantee
- Check a byte-string palindrome without a reversed copy
- Classes, Constructors & Destructors
- Concurrency: Threads, Mutex & Atomics
- Copy Control: Rule of 3/5/0
- Find distinct indices with a target sum using a hash map
- Functions Reference: STL & string
- Functions, Overloading & Lambdas
- How can vector growth invalidate a perfectly valid pointer?
- How do references differ from pointers in an API?
- How would you design a resource-owning container with strong exception safety?
- Implement a minimal move-only owner for one int
- Implement an LRU cache with stable list iterators
- Inheritance & Virtual Functions
- Introduction & I/O
- Iterators & STL Algorithms
- Modern C++ Features (17/20/23)
- Move Semantics & Rvalue References
- Operator Overloading
- RAII & Smart Pointers
- Return the first matching index in a sorted vector
- STL Containers
- Templates & Concepts
- Types, References & auto
- Why does RAII clean up correctly during exceptions?
- Why doesn’t std::move necessarily move an object?
- Why is a C++ data race more serious than a lost update?
Can't find a C++ topic you need for exams or placements? Request it and we'll add it.