← All interview questions

Skill Zuno · skillzunos.com · Fullstack

C ++ interview questions

Prepare for C ++ interviews on Skill Zuno. This practice book covers C ++ interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.

Open C ++ on Skill Zuno

Also see the C ++ tutorial.

C++ is a compiled, statically typed language that offers low-level memory control together with classes, templates and a rich standard library. It powers game engines, browsers, trading systems and embedded software. C++ interviews cover RAII, smart pointers, move semantics, virtual functions, templates and the STL.

Sample C ++ interview questions

What is RAII?

Resource Acquisition Is Initialization ties a resource's lifetime to an object: the constructor acquires it and the destructor releases it. Because destructors run when objects leave scope, even during exceptions, resources are never leaked.

What is the difference between unique_ptr and shared_ptr?

unique_ptr has a single owner, cannot be copied, only moved, and costs nothing over a raw pointer. shared_ptr uses a reference count so several owners share the object, which is deleted when the last one goes away.

What does std::move do?

std::move does not move anything: it casts its argument to an rvalue reference, which lets the move constructor or move assignment operator steal the object's resources instead of copying them.

Why should a base class have a virtual destructor?

Deleting a derived object through a base-class pointer calls only the base destructor unless it is virtual. That is undefined behaviour and in practice leaks whatever the derived class owns.

What is the rule of five?

If a class defines one of the destructor, copy constructor, copy assignment, move constructor or move assignment, it probably needs all five. The rule of zero says to prefer members such as smart pointers that manage themselves, so none are needed.

What you can practice

  • C ++ interview questions for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack topics alongside C ++ on skillzunos.com

More Fullstack interview questions

All interview questions