Interview Q&A · C++ · 12 questions in this topic
Rapid-Fire Revision — C++ Interview Q&A
One-line answers spanning the whole bank — the final pass the night before the interview. Part of Scenarios & Rapid Fire · 213 questions in the C++ bank.
This rapid-fire round distils the C++ bank into short answers for the final pass. The cards target distinctions that separate a working answer from a precise one: value versus reference parameters, object lifetime and RAII, virtual dispatch, and undefined behaviour in the standard library. Each answer is a starting point — be ready to name the rule that makes it true, and open the full topic when you need the example rather than the summary. For each card, also name the standard rule or lifetime boundary that the answer depends on.
Compiled or interpreted?
Answer
Compiled — to native machine code via object files and linking (no VM by default).
Statically or dynamically typed?
Answer
Statically typed — types fixed and checked at compile time.
Pointer vs reference?
Answer
Pointer: nullable, reseatable address. Reference: must-bind alias, never null, never reseated.
new vs malloc?
Answer
new constructs objects and throws; malloc allocates raw bytes and returns null.
What is RAII?
Answer
Resource lifetime bound to object lifetime — constructor acquires, destructor releases.
unique_ptr vs shared_ptr vs weak_ptr?
Answer
Exclusive ownership; shared counted ownership; non-owning observer that breaks cycles.
Rule of 0/3/5?
Answer
Manage nothing (0), or define destructor+copy+move as a package (5).
Virtual destructor when?
Answer
Whenever a class is deleted polymorphically through a base pointer.
override vs final?
Answer
override checks you really override; final seals against further override/inheritance.
map vs unordered_map?
Answer
Ordered tree O(log n) with sorted iteration vs hash table average O(1) with no order.
What invalidates vector iterators?
Answer
Reallocation (growth past capacity) and insert/erase at or before the position.
What is a data race?
Answer
Unsynchronized concurrent accesses with at least one write — undefined behavior.
Recommended resourcesAffiliate links · may earn us a commission