C++ Interview Questions (2026): By Level, With Model Answers

How to use this

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?

What a strong answer covers

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.

Red flag

Thinks references can be null or reseated.

What is the difference between stack and heap allocation?

What a strong answer covers

Stack allocation is automatic and fast with scope-bound lifetime; heap (new) is manual, flexible and must be freed.

Red flag

Uses new for everything and leaks memory.

What is a memory leak and how does it happen?

What a strong answer covers

Allocated memory that is never freed because its pointer is lost; smart pointers and RAII prevent most leaks.

Red flag

Manually new/deletes with no ownership discipline.

What is the difference between struct and class?

What a strong answer covers

Only the default access level (public vs private); otherwise identical. They use convention to distinguish intent.

Red flag

Believes they differ fundamentally.

What does const mean in different positions?

What a strong answer covers

It marks values, pointers, pointees or member functions as non-modifying; const-correctness documents and enforces intent.

Red flag

Ignores const-correctness entirely.

What is the difference between pass by value and by reference?

What a strong answer covers

By value copies (safe but potentially costly); by reference avoids the copy, and const& avoids copying without allowing mutation.

Red flag

Passes large objects by value everywhere.

What is a constructor and destructor?

What a strong answer covers

The constructor initialises an object; the destructor releases its resources when it goes out of scope — the basis of RAII.

Red flag

Forgets to release resources in the destructor.

What are header and source files for?

What a strong answer covers

Headers declare interfaces; source files define them; include guards or #pragma once prevent double inclusion.

Red flag

Puts definitions in headers and gets link errors.

Mid-level C++ interview questions

2–5 years

RAII and modern C++.

What is RAII?

What a strong answer covers

Resource Acquisition Is Initialization: tie a resource’s lifetime to an object so it’s released deterministically in the destructor.

Red flag

Manually manages resources and leaks on early return/exception.

What are smart pointers and when do you use each?

What a strong answer covers

unique_ptr for exclusive ownership, shared_ptr for shared ownership, weak_ptr to break cycles; prefer them over raw new/delete.

Red flag

Uses raw owning pointers in modern code.

What are move semantics and rvalue references?

What a strong answer covers

Moving transfers resources instead of copying, avoiding expensive deep copies; rvalue references and std::move enable it.

Red flag

Copies large objects where a move would do.

What is the Rule of Three/Five/Zero?

What a strong answer covers

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).

Red flag

Defines a destructor but forgets copy/move and corrupts memory.

What is the difference between std::vector and std::list?

What a strong answer covers

Vector is contiguous with fast random access and cache locality; list is a linked list with cheap mid-insertion but poor locality.

Red flag

Defaults to list and suffers cache misses.

What are templates?

What a strong answer covers

Compile-time generic code parameterised by type, enabling reuse without runtime cost.

Red flag

Duplicates functions per type instead.

What is undefined behaviour and why does it matter?

What a strong answer covers

Operations the standard doesn’t define (out-of-bounds access, use-after-free) can do anything; it’s a top source of security bugs.

Red flag

Treats a program that “works” as correct despite UB.

What is the difference between new/delete and malloc/free?

What a strong answer covers

new/delete call constructors/destructors and are type-aware; malloc/free just allocate raw memory.

Red flag

Mixes them and skips construction/destruction.

Senior C++ interview questions

5+ years

Performance and design.

How do you reason about performance in C++?

What a strong answer covers

Understand cache behaviour, avoid unnecessary allocations and copies, measure with a profiler, and prefer contiguous data structures.

Red flag

Optimises by intuition without profiling.

How do you write exception-safe code?

What a strong answer covers

Provide strong/basic guarantees using RAII so resources are released on any exit path, and be mindful of noexcept.

Red flag

Leaks resources when an exception unwinds.

What is the difference between compile-time and runtime polymorphism?

What a strong answer covers

Templates/CRTP resolve at compile time with no vtable cost; virtual functions dispatch at runtime with flexibility.

Red flag

Uses virtual dispatch in hot paths without considering cost.

How do you avoid data races in multithreaded C++?

What a strong answer covers

Mutexes, atomics and the memory model, or better, minimise shared mutable state and use higher-level abstractions.

Red flag

Shares mutable state across threads with no synchronisation.

What do you know about the C++ memory model and atomics?

What a strong answer covers

It defines ordering guarantees for concurrent access; atomics with the right memory ordering enable correct lock-free code.

Red flag

Assumes reads/writes are atomic and ordered by default.

When do you use move vs copy elision?

What a strong answer covers

The compiler can elide copies (RVO); understanding it avoids premature std::move that can pessimise.

Red flag

Adds std::move on returns and defeats RVO.

How do you manage ownership in a large codebase?

What a strong answer covers

Clear ownership via smart pointers, value semantics where possible, and documented lifetimes to prevent dangling references.

Red flag

Ambiguous ownership and dangling pointers everywhere.

What modern C++ features most improve safety and clarity?

What a strong answer covers

Smart pointers, auto, range-based loops, constexpr, structured bindings, and standard algorithms over raw loops.

Red flag

Writes C-style C++ ignoring the standard library.

Skip the screening entirely.We vet C++ engineers so you don’t have to — embed one in your team, or have us build it.

Hire C++ developersCompare us

Build and score a full interview with our free interview scorecard tool, browse the full question hub, or see how we interview engineers.

Share