C++ gives you total control and total responsibility. These questions check whether a candidate understands memory, RAII and modern C++, not just C-with-classes.
Hiring a C++ developer is easy. Telling a real one from a convincing résumé is the hard part — and it’s most of what we do. These are grouped by level, because the same question that stretches a junior is a warm-up for a senior.
Junior C++ interview questions
0–2 years
Fundamentals.
What is the difference between a pointer and a reference?
A pointer is a variable holding an address that can be null and reseated; a reference is an alias that must bind on creation and can’t be null or rebound.
Thinks references can be null or reseated.
What is the difference between stack and heap allocation?
Stack allocation is automatic and fast with scope-bound lifetime; heap (new) is manual, flexible and must be freed.
Uses new for everything and leaks memory.
What is a memory leak and how does it happen?
Allocated memory that is never freed because its pointer is lost; smart pointers and RAII prevent most leaks.
Manually new/deletes with no ownership discipline.
What is the difference between struct and class?
Only the default access level (public vs private); otherwise identical. They use convention to distinguish intent.
Believes they differ fundamentally.
What does const mean in different positions?
It marks values, pointers, pointees or member functions as non-modifying; const-correctness documents and enforces intent.
Ignores const-correctness entirely.
What is the difference between pass by value and by reference?
By value copies (safe but potentially costly); by reference avoids the copy, and const& avoids copying without allowing mutation.
Passes large objects by value everywhere.
What is a constructor and destructor?
The constructor initialises an object; the destructor releases its resources when it goes out of scope — the basis of RAII.
Forgets to release resources in the destructor.
What are header and source files for?
Headers declare interfaces; source files define them; include guards or #pragma once prevent double inclusion.
Puts definitions in headers and gets link errors.
Mid-level C++ interview questions
2–5 years
RAII and modern C++.
What is RAII?
Resource Acquisition Is Initialization: tie a resource’s lifetime to an object so it’s released deterministically in the destructor.
Manually manages resources and leaks on early return/exception.
What are smart pointers and when do you use each?
unique_ptr for exclusive ownership, shared_ptr for shared ownership, weak_ptr to break cycles; prefer them over raw new/delete.
Uses raw owning pointers in modern code.
What are move semantics and rvalue references?
Moving transfers resources instead of copying, avoiding expensive deep copies; rvalue references and std::move enable it.
Copies large objects where a move would do.
What is the Rule of Three/Five/Zero?
If you define one of destructor/copy/move operations you likely need the others; better yet, use RAII types and define none (Rule of Zero).
Defines a destructor but forgets copy/move and corrupts memory.
What is the difference between std::vector and std::list?
Vector is contiguous with fast random access and cache locality; list is a linked list with cheap mid-insertion but poor locality.
Defaults to list and suffers cache misses.
What are templates?
Compile-time generic code parameterised by type, enabling reuse without runtime cost.
Duplicates functions per type instead.
What is undefined behaviour and why does it matter?
Operations the standard doesn’t define (out-of-bounds access, use-after-free) can do anything; it’s a top source of security bugs.
Treats a program that “works” as correct despite UB.
What is the difference between new/delete and malloc/free?
new/delete call constructors/destructors and are type-aware; malloc/free just allocate raw memory.
Mixes them and skips construction/destruction.
Senior C++ interview questions
5+ years
Performance and design.
How do you reason about performance in C++?
Understand cache behaviour, avoid unnecessary allocations and copies, measure with a profiler, and prefer contiguous data structures.
Optimises by intuition without profiling.
How do you write exception-safe code?
Provide strong/basic guarantees using RAII so resources are released on any exit path, and be mindful of noexcept.
Leaks resources when an exception unwinds.
What is the difference between compile-time and runtime polymorphism?
Templates/CRTP resolve at compile time with no vtable cost; virtual functions dispatch at runtime with flexibility.
Uses virtual dispatch in hot paths without considering cost.
How do you avoid data races in multithreaded C++?
Mutexes, atomics and the memory model, or better, minimise shared mutable state and use higher-level abstractions.
Shares mutable state across threads with no synchronisation.
What do you know about the C++ memory model and atomics?
It defines ordering guarantees for concurrent access; atomics with the right memory ordering enable correct lock-free code.
Assumes reads/writes are atomic and ordered by default.
When do you use move vs copy elision?
The compiler can elide copies (RVO); understanding it avoids premature std::move that can pessimise.
Adds std::move on returns and defeats RVO.
How do you manage ownership in a large codebase?
Clear ownership via smart pointers, value semantics where possible, and documented lifetimes to prevent dangling references.
Ambiguous ownership and dangling pointers everywhere.
What modern C++ features most improve safety and clarity?
Smart pointers, auto, range-based loops, constexpr, structured bindings, and standard algorithms over raw loops.
Writes C-style C++ ignoring the standard library.
Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.