ProAdvancedInterview prep

C++ Interview Questions

Ten spines of the C++ questions that separate people who have read the documentation from people who have hit the behaviour in production: ownership and the Rule of Five, virtual destructors and slicing, shared_ptr cycles, move semantics, const, dispatch, iterator invalidation, initialisation order, and the classic undefined behaviour every interviewer expects you to name. Every snippet compiles and runs the same way twice - the traps here are conceptual, never machine-dependent.

Questions90
Topics10
Answering time68 minutes
At five a day18 days
LevelAdvanced

Who it is for

Preparing, and short of time.

For someone confident in the language who wants the traps, the edge cases and the interview questions.

You will get the most out of it if you have written C++ recently enough to read it without effort, and have been surprised by it at least once. If you are picking the language up for the first time, start with C++ Essentials and come back to this one.

It is also built for interview preparation: the questions are the ones that get asked because they separate people who have read the documentation from people who have hit the behaviour in production.

How long it takes

90 graded questions at roughly 45 seconds each is about 68 minutes of answering in total.

At the default five questions a day, and because the session mixes in your other courses, expect around 18 days — call it 3 weeks — to see everything once, plus a few weeks of thinning reviews after that before it is all mastered.

A question is mastered on the third correct answer, once the gap between reviews has grown past a week — so a course cannot be finished in a weekend however long you sit with it.

Question mix

  • 60 multiple choice
  • 10 concept cards
  • 10 predict the output
  • 10 put it in order
  • 10 matching questions

Syllabus

What you will be asked about

  1. 01

    Rule of Five

    Say which special members a class needs once it owns a resource.

  2. 02

    Virtual Destructors

    Say what deleting a derived object through a base pointer does without one.

  3. 03

    Slicing and Polymorphism

    Predict what is left after a derived object is copied into a base.

  4. 04

    shared_ptr Cycles

    Find the cycle that leaks, and the weak_ptr that breaks it.

  5. 05

    Move Semantics

    Say what a moved-from object is guaranteed to be.

  6. 06

    const and mutable

    Tell what const protects, including what mutable carves out.

  7. 07

    Static vs Dynamic Dispatch

    Decide which call is resolved when, including in constructors.

  8. 08

    Iterator Invalidation

    Say which loop is safe and which has already broken.

  9. 09

    Initialisation Order

    Predict member initialisation order, and the static initialisation order problem.

  10. 10

    Undefined Behaviour Classics

    Recognise the classic UB and say why it is not just "works on my machine".

8 more topics, and all 90 questions

C++ Interview Questions is a Pro course. One subscription opens it and every other course in the catalogue, including the ones still being written.

See pricing Find a free course

A question from this course

Rule of Five

What does this print?

#include <iostream>
class Box {
public:
    int* data;
    Box(int v) : data(new int(v)) {}
    Box(const Box& other) : data(new int(*other.data)) {
        std::cout << "copy ";
    }
    ~Box() { delete data; }
};
int main() {
    Box a(1);
    Box b = a;
    *b.data = 99;
    std::cout << *a.data << " " << *b.data << std::endl;
    return 0;
}
  • Acopy 99 99
  • Bcopy 1 1
  • Ccopy 1 99
  • D1 99
Show the answer

C copy 1 99

The hand-written copy constructor allocates its own int and copies the value in, so a and b own two separate heap ints from the start. Changing *b.data through b afterward cannot touch a's copy - if it could, that would mean the copy constructor had only copied the pointer, which is the shallow-copy bug this class was written to avoid.

The rest of the track

C++ at every depth

FreeFoundation

C++ Essentials

Covers value semantics and copies, references versus pointers, const in each position, auto deduction, range-for aliasing, std::string and std::vector basics, overload resolution with default arguments, aggregate initialisation, and stream output - the behaviours that surprise someone who already knows C++'s syntax. Every snippet compiles and runs against a real compiler, so the traps are proven, not just asserted.

90 questions · 68 minutes

ProCore

C++ Core

Covers copy versus move, the rule of three and five, temporary and reference lifetime, the three initialization forms and their narrowing rules, implicit conversions and explicit, parameters by value and by reference, function-local static storage, slicing on inheritance, virtual dispatch, and RAII. Aimed at someone who already writes C++ daily but has never had the gap between what compiles and what is correct made explicit.

90 questions · 68 minutes

ProCore

C++ Collections

Every container in the standard library keeps a different, precise promise about growth, ordering and cost - and the surprises show up exactly where those promises are assumed rather than checked. This course puts pressure on comfortable C++: which references a push_back invalidates, why operator[] silently inserts, when a set drops what you gave it, and what emplace really skips that insert does not. It is for someone comfortable writing C++ who has never been made to justify what a container guarantees.

90 questions · 68 minutes

ProCoreInterview prep

C++ Errors & Edge Cases

Most C++ code you write handles the case where everything works; this course is about what happens when it does not. It covers stack unwinding and destructor order, why catching by reference matters, how noexcept and throwing destructors reach std::terminate, the three tiers of exception safety, RAII versus manual cleanup, std::optional as a sentinel replacement, error codes versus exceptions, checked versus unchecked bounds access, and how a bare rethrow really propagates.

90 questions · 68 minutes

ProCore

C++ Standard Library

For a reader who reaches for a dependency before checking what the standard library already provides. Works through the C++17 vocabulary types, RAII smart pointers, the algorithms header, iostream formatting, and chrono durations, with every answer checked against what actually compiles and runs.

90 questions · 68 minutes

ProAdvanced

C++ Idioms

For a reader who already gets C++ syntax but still reaches for a cleanup function, a raw new, or a hand-rolled loop out of habit from Java, C, or Python. Works through RAII replacing manual cleanup, value semantics versus the heap, the standard algorithms a loop is usually reimplementing, parameter passing by const reference, move semantics, scope guards, if constexpr, the rule of zero, argument-dependent lookup and hidden friends, and the reserve-and-emplace patterns that avoid extra copies. Every example compiles and runs, and the questions target the exact point where fluent-but-foreign C++ habits produce working code that is not idiomatic.

90 questions · 68 minutes

ProAdvancedInterview prep

C++ Advanced

Templates, forwarding, CRTP, folds, lambda captures, overload resolution and constexpr - the parts of C++ that only bite once a codebase gets large. Every answer here is guaranteed by the standard, not by one compiler's mood on one machine.

90 questions · 68 minutes

ProAdvancedInterview prep

C++ Performance

Costs you can count instead of guess: copy and move construction proven by an instrumented class, what reserve does and does not remove, by-value versus const& parameters, the returns C++17 actually guarantees to elide, string concatenation, container and algorithm choice, struct layout reasoned about rather than measured, shared_ptr's atomic reference count, and when virtual dispatch is worth its indirection. Every answer here is a count or a printed fact, checked by compiling and running the code - never a clock reading. It is written for someone who has never profiled anything and reasons about speed from folklore - "moves are cheap," "references avoid copies," "virtual is slow" - and needs each claim replaced with something they compiled themselves. No timing, no benchmarks: just what a program can prove about itself.

90 questions · 68 minutes

ProCore

C++ Testing

Ten spines on testing C++ the way it actually gets tested: separating a pure decision from its side effect, injecting a dependency instead of reaching for a global, and telling a test double that proves something from one that only looks reassuring. Every graded snippet compiles as a plain program with a tiny check()-style helper - no gtest, no catch2 - and is checked to give the same answer on both x86-64 and arm64. Written for someone who tests the code they wrote rather than the code they meant, and who writes tests that can pass for the wrong reason without noticing.

90 questions · 68 minutes

Start C++ Interview Questions
in tomorrow’s session.

Enrol and this course joins your daily five, mixed in with everything else you are studying — 90 questions spread over about 18 days rather than dropped on you at once.

Browse the catalogue