Top 50 C++ Interview Questions for 2026
C++ interviews split cleanly into three audiences: HFT/quant shops, systems infra (databases, kernels, search engines), and games/embedded. The language overlap is large but the emphasis differs. HFT cares about cache lines and lock-free queues. Infra cares about lifetimes and concurrency primitives. Games care about allocators and SIMD.
These 50 questions cover the common core. If you are targeting one specialty, push deeper into its section.
Language Fundamentals (1-12)
- What is RAII, and what is the canonical example you would show a junior engineer?
- Walk me through the rule of zero, three, and five. When did C++11 force the rule of five into existence?
- What is the difference between
const,constexpr,consteval, andconstinit? - Explain copy elision, RVO, and NRVO. What changed in C++17 about guaranteed copy elision?
- What is a trivially copyable type, and why does the standard care?
std::string_viewvsconst std::string&for a function parameter - pick one and defend it.- What is the difference between
final,override, andvirtualon a member function? - Explain how virtual dispatch works under the hood. Where does the vtable live?
- What is the empty base optimization and why does the standard library lean on it?
enumvsenum class- when does the difference bite you in practice?- What is
std::launderand when have you needed it? - Walk me through the lifetime of a temporary. When does a dangling reference happen "by accident"?
Move Semantics & Ownership (13-22)
- What does
std::moveactually do? (Hint: nothing, until something else picks it up.) - Why is the move constructor allowed to be
noexcept-marked, and why does it matter forstd::vector? - What is reference collapsing, and what is a forwarding (universal) reference?
- Explain
std::forwardand where mis-using it silently breaks generic code. unique_ptrvsshared_ptrvsweak_ptr- pick one for: a tree node parent, an observer, a polymorphic factory return type.- How does
shared_ptrreference counting actually work? What is the control block, and where does it live? - What is
make_sharedvsshared_ptr<T>(new T), and what is the gotcha whenThas a private destructor? - What is a sink parameter, and how do you implement one cleanly today (perfect forwarding, by value, etc.)?
- When does a destructor run for a thrown exception? What does
std::terminatehave to do with it? - Walk me through "you can do everything
unique_ptrdoes withboost::scoped_ptr" - what didunique_ptradd?
Templates & Generic Programming (23-30)
- What is SFINAE, and why has C++20 made it half-obsolete with concepts?
- Walk me through writing a concept that constrains a type to "looks like a container."
- What is CRTP, and what runtime cost does it remove vs virtual dispatch?
- Variadic templates - implement
tupleat a whiteboard level. Where does the compile-time recursion go? - What is
if constexpr, and what readability problem did it fix? - Explain template argument deduction guides. When do you need to write one?
- What is two-phase name lookup, and why is
template<class T> struct Foo : Base<T>painful? - What is a fold expression, and what is one realistic use beyond a
printhelper?
Memory Model & Concurrency (31-40)
- Walk me through the C++ memory model. What is "happens-before"?
std::atomicmemory orders -relaxed,acquire,release,acq_rel,seq_cst. Pick the right one for a counter and for a flag.- What is the difference between a data race and a race condition?
- How does
std::mutexdiffer fromstd::shared_mutex? When is the shared variant a footgun under contention? - What is
std::condition_variable, and what is the textbook bug pattern people write with it? std::threadvsstd::jthread. What did C++20 fix?- What is
std::stop_token, and how does it cooperate with cancellation? - Implement a single-producer / single-consumer ring buffer. What memory ordering do the head/tail pointers need?
- False sharing - what is it, how do you find it, and how do you fix it without
alignas(64)everywhere? - What is
std::futureandstd::promise, and why does almost no shop use them in production?
Performance & Systems (41-46)
- What is cache-line size on a modern x86 server, and how does it shape data structure design?
- SIMD via intrinsics vs
<execution>parallel algorithms vs hand-rolled assembly - when does each pay off? - What is "small string optimization," and how do you tell whether a
std::stringis using it? - How do allocators work in C++17/20 (
std::pmr)? When would you write a custom one? - Walk me through profiling a hot loop with
perfand turning a 30% CPU function into 5%. - How do you reduce binary size on a release build that has grown to 200 MB?
Modern C++ & Style (47-50)
- What did C++20 modules change about build times in practice? Have you used them in anger?
- Coroutines in C++20 - explain the customization-point soup (
promise_type,awaiter,co_await). When are they actually nice to use? - Ranges - what does
views::filter | views::transform | views::takeactually compile to? - How do you keep a large C++ codebase from drifting into 5 dialects? What linters and CI gates earn their keep?
How to Use This List
C++ interviewers smell memorization fast. Practice answering these with examples from your own code - even toy projects count. Pull the example off your laptop, walk through it, name the tradeoff you actually made.
If you can do that for all 50, you are ready.
Drill these in mock-interview format with instant feedback on gitGood. $5/month, no annual lock-in.