P
prepair.app
Start interview →
EnglishУкраїнськаРусский
🔷

Junior C++C++ interview questions

Junior · no experience / under 1 year

C++ interviews test three things: whether you understand the object model, whether you can be trusted with memory, and whether you know what the standard library costs. Below are the questions asked most often, each with a model answer. Junior: core theory, definitions, and simple practical cases.

Topics to prepare

Memory, pointers and RAII
OOP, virtual functions and vtable
Move semantics and the rule of five
Templates and metaprogramming
STL containers and complexity
Concurrency and data races

7 Junior-level questions with answers

1

What is the difference between a pointer and a reference?

Answer

A reference is bound once and cannot be null or rebound; a pointer can be null, can be reassigned, and supports arithmetic. Use a reference when the object must exist, a pointer when it might not. Because a reference is an alias rather than an object, &ref gives you the address of the referent.

2

Where do variables live — stack, heap or static storage?

Answer

Locals live on the stack and die at the end of their scope. Anything from new lives on the heap until something deletes it. Globals and static variables live in static storage for the whole program. Knowing which you are in answers most lifetime questions, including why returning the address of a local is broken.

3

What does `static` mean in C++?

Answer

Three different things depending on where it is. On a local variable it means one instance that survives between calls. On a global or function at file scope it means internal linkage — not visible to other translation units. On a class member it means one shared instance belonging to the class rather than to each object, and a static method has no this.

4

What is the difference between a `const` pointer and a pointer to `const`?

Answer

const int* p points at something you may not modify — the pointer itself is free to move. int* const p is a pointer you cannot repoint, but the value it points at is writable. Reading the declaration right to left makes this mechanical rather than a memory exercise, and const int* const p is both.

5

What is the difference between `delete` and `delete[]`, and what is a memory leak?

Answer

delete matches new, delete[] matches new[]; mixing them is undefined behaviour because the array form has to run every element's destructor. A leak is memory that was allocated and never released — the program keeps holding it, and a long-running process grows until it dies. Smart pointers exist so that neither mistake is possible.

6

What is the difference between a `class` and a `struct`?

Answer

Only the default access: struct members are public by default, class members are private. Both can have constructors, methods and inheritance. The distinction is a convention — struct for plain aggregates of data, class when there are invariants to protect.

7

What is polymorphism and how does `virtual` provide it?

Answer

Polymorphism is calling the same interface and getting the behaviour of the actual type. Marking a member function virtual means the call is resolved from the object's dynamic type at runtime instead of the pointer's static type. Without virtual, calling through a base pointer runs the base version, which is the most common source of surprise for people learning the language.

🦎

Reading answers is not enough

In a real interview you speak under pressure. Cam asks these same questions, scores every answer, and shows exactly what to fix.

Practice a Junior C++ interview →
Free · 3 interviews per month

Other levels — C++

Middle C++Senior C++All C++ questions

Other specializations

🔍Junior Manual QA🤖Junior QA AutomationJunior Java Backend🐍Junior Python Backend🐘Junior PHP Backend🦫Junior Go Backend🟢Junior Node.js Backend💎Junior Ruby on Rails🟨Junior JavaScript⚛️Junior React Frontend