C++ track

C++ interview questions and answers

Panel-ready C++ interview set questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.

21 Moderate Smart pointers C++

unique_ptr versus shared_ptr?

Short take Full answer on next page

Simple meaning

Unique_ptr is exclusive ownership, zero overhead, move-only.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
22 Moderate Smart pointers C++

When do you need weak_ptr?

Short take Full answer on next page

Simple meaning

To break shared_ptr cycles, like parent-child observers.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
23 Moderate Move C++

What are move semantics?

Short take Full answer on next page

Simple meaning

A move constructor steals resources from an rvalue so we copy pointers, not buffers.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
24 Moderate Templates C++

What is a function template?

Short take Full answer on next page

Simple meaning

The compiler generates a function per type I call it with.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
25 Moderate OOP C++

What is the diamond problem?

Short take Full answer on next page

Simple meaning

Two bases share a grand-base, so a derived object would get two copies of the grand-base.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
26 Moderate OOP C++

What is a vtable?

Short take Full answer on next page

Simple meaning

A per-class table of function pointers for virtual methods.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
28 Moderate Language C++

What is a lambda in C++?

Short take Full answer on next page

Simple meaning

An anonymous function object.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
29 Moderate Exceptions C++

What is exception safety?

Short take Full answer on next page

Simple meaning

The basic guarantee leaves the program valid

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
31 High Templates C++

What is SFINAE?

Short take Full answer on next page

Simple meaning

Substitution failure is not an error: a bad template candidate is dropped instead of failing the whole program.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
32 High Concurrency C++

What is a data race?

Short take Full answer on next page

Simple meaning

Two threads access the same memory, at least one writes, with no happens-before.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
33 High Language C++

What is the one-definition rule?

Short take Full answer on next page

Simple meaning

A function or variable can be defined only once in the program, with exceptions for inline and templates.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
38 Moderate OOP C++

What is a virtual function?

Short take Full answer on next page

Simple meaning

Virtual enables dynamic dispatch so a base pointer can call the derived override.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
39 Moderate Memory C++

What are smart pointers and why use them?

Short take Full answer on next page

Simple meaning

unique_ptr and shared_ptr manage lifetime automatically so I rarely call delete.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
40 High STL C++

When do you choose vector over list?

Short take Full answer on next page

Simple meaning

vector is contiguous, cache-friendly, and great for random access.

Open the full page for Why, Steps, Example and Key takeaway.

Read full answer Example · Mistake · Say this
Prev Page 2 of 11 Next
Chat with us