C++ Last-Minute Revision
Quickly revise the questions you picked. Add questions from the interview-questions lists with Save to → Last-Minute Revision.
30 quick revision notes for C++
- The compile pipeline is preprocess, compile, assemble and link; a missing function body causes a linker error, not a compile error.
- The One Definition Rule allows many declarations but exactly one definition of each non-inline function or variable in the program.
- Signed integer overflow, out-of-bounds access and reading uninitialised variables are undefined behaviour, which optimisers assume never happens.
- Pass small types by value, large read-only objects by const reference and use references or pointers for output parameters.
- struct and class differ only in default access: struct is public by default and class is private by default.
- A static local variable is initialised once and its initialisation is thread-safe since C++11.
- constexpr allows compile-time evaluation; consteval forces it; const only prevents modification after initialisation.
- Stack allocation is fast and automatic, while heap allocation is slower, larger and must be released by an owner.
- RAII ties resource release to destructors, so files, locks and memory are freed even when exceptions are thrown.
- unique_ptr is move-only sole ownership, shared_ptr is reference counted, and weak_ptr observes without owning and breaks cycles.
- Always pair new with delete and new[] with delete[]; never mix new with free or malloc with delete.
- A base class used polymorphically needs a virtual destructor, otherwise deleting through a base pointer is undefined behaviour.
- Virtual calls go through a vtable pointer stored in each object, adding an indirect call and usually blocking inlining.
- Object slicing happens when a derived object is copied into a base by value, losing derived data and behaviour.
- Rule of zero: prefer members like vector, string and unique_ptr so you never need custom copy, move or destructor code.
- Mark single-argument constructors explicit to prevent surprising implicit conversions such as an int silently becoming a Money object.
- Templates must usually be defined in headers because code is generated only where they are instantiated with concrete types.
- C++20 concepts constrain templates and produce short, readable errors compared with SFINAE and enable_if.
- vector gives contiguous storage, O(1) random access and amortised O(1) push_back; reallocation invalidates all iterators.
- map is an ordered tree with O(log n) operations; unordered_map is a hash table with average O(1) operations.
- std::remove only shifts elements; combine it with erase, or use std::erase and std::erase_if from C++20.
- std::move is only a cast to an rvalue reference; the actual move happens in the move constructor or move assignment.
- Move constructors should be noexcept so std::vector moves instead of copies during reallocation.
- string_view does not own data, so it must never outlive the string or buffer it refers to.
- A joinable std::thread destroyed without join or detach calls std::terminate; std::jthread joins automatically.
- Always wait on a condition variable with a predicate, because spurious wakeups can occur.
- Avoid deadlock by locking mutexes in a fixed order or locking them together with std::scoped_lock.
- False sharing occurs when threads write different variables on the same 64-byte cache line; pad hot data with alignas(64).
- AddressSanitizer finds memory errors, UBSan finds undefined behaviour, and ThreadSanitizer finds data races.
- Optimise by measuring first: create a benchmark, profile with perf, fix the biggest hotspot and measure again.
Night-before checklist
- Revise your saved questions on this page once, aloud.
- Read the quick notes and mark any you cannot explain in one line.
- Rehearse a two-minute self-introduction and two project stories.
- Keep CV, ID, laptop charger and interview link ready; sleep on time.
Frequently asked questions
How does Last-Minute Revision work?
On any question page, open Save to → Last-Minute Revision. Saved questions appear here with their answers, so the night before an interview you revise only what you found hard.
Is my list saved?
Yes, in this browser. Guests can save 5 questions; free accounts can save 20 for revision and 100 for the 7-day plan.
What should I revise last before a C++ interview?
Your saved misses first, then the quick notes on this page, then one or two project stories. Avoid learning brand-new topics the night before.
Find questions to save
Company-wise C++ questionsExperience-wise C++ questionsRole-wise C++ questionsCity-wise C++ questionsMost asked C++ questionsScenario-based questionsPractical / hands-on questionsHR & behavioural questionsC++ mock interviewOnline assessment questionsTechnical round questionsManagerial round questionsC++ topic sheets