Memory and ownership
- RAII - what it is and why it is the organising idea of modern C++. Resources tied to object lifetime, released in the destructor.
- `unique_ptr` versus `shared_ptr` versus `weak_ptr`, and the reference cycle that `weak_ptr` exists to break.
- Why is `make_unique` or `make_shared` preferred over a bare `new`?
- Stack versus heap, and why stack allocation is both faster and safer.
- What is a dangling pointer, and what is use-after-free? Expect a code sample.
- What does `delete` on an array allocated with `new[]` do? Undefined behaviour - and knowing to say "undefined behaviour" rather than guessing is itself the signal.
The rule of three, five and zero
- Copy constructor, copy assignment and destructor - and when the compiler-generated versions are wrong.
- Move constructor and move assignment, and what a moved-from object is allowed to be (valid but unspecified).
- The rule of zero - design so you need none of them, by holding resources in types that manage themselves.
- What `std::move` actually does. It casts; it does not move anything.
Language mechanics
- Virtual functions and the vtable, and why a base class with virtual methods needs a virtual destructor.
- `const` correctness, including const member functions and what `mutable` is for.
- References versus pointers, and when a reference cannot do the job.
- Templates - and what happens at compile time rather than runtime.
- `static` at file, function and class scope - three different meanings.
Modern C++ and performance
Expect questions about which standard the team uses and what you reach for from it - structured bindings, `optional`, `string_view`, range-based for. On performance: cache locality and why a vector usually beats a list, the cost of virtual dispatch, and how you would measure before optimising. The algorithmic half is the same as any loop - see the 15 LeetCode patterns.
How deep it goes by level
- Junior: the fundamentals above, explained clearly. Nobody expects production scars yet, and honesty about what you have not done reads better than bluffing.
- Mid-level: the same ground, plus code you have debugged with a sanitiser. Expect follow-ups asking why you made a particular choice rather than whether you know the syntax.
- Senior: which standard your team targets, and a performance problem you measured rather than guessed. At this level the language questions get shorter and the judgement questions get longer.
Whatever the level, the reliable way to prepare is to say your answers out loud rather than reading them. Most of what candidates lose in a C++ interview is lost in the gap between knowing something and explaining it under observation - the method is in how to use AI for interview prep.
Where CoPilot Interview fits
Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.
Frequently asked questions
What are the most common C++ interview questions?
RAII and smart pointer choice, the rule of three or five, move semantics and what `std::move` actually does, virtual destructors, and `const` correctness. Most questions reduce to ownership: who allocated a resource and who releases it.
What does std::move actually do?
Nothing at runtime - it is a cast to an rvalue reference that makes the object eligible for a move operation. The move itself is performed by a move constructor or move assignment operator if one exists; otherwise a copy still happens.
Why does a base class need a virtual destructor?
Deleting a derived object through a base class pointer when the base destructor is non-virtual is undefined behaviour, and in practice the derived destructor does not run, leaking its resources. Any class intended for polymorphic deletion needs one.
What is the rule of zero?
Design classes so they need no user-defined copy, move or destructor operations, by holding resources in types that already manage themselves such as smart pointers and containers. It is the preferred modern approach over writing the rule of five by hand.
Walk into the round with a second pair of eyes
CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.
Try it free