← All interview questions

Skill Zuno · skillzunos.com · Fullstack

CPP Design Patterns interview questions

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

Open CPP Design Patterns on Skill Zuno

Also see the CPP Design Patterns tutorial.

Design patterns in C++ combine classic object-oriented designs with language features such as RAII, templates, move semantics and lambdas. Many patterns take a C++-specific form, such as CRTP for static polymorphism, the pimpl idiom and policy-based design. Interviews test both Gang of Four patterns and modern C++ idioms.

Sample CPP Design Patterns interview questions

What is the pimpl idiom?

The class holds only a pointer, usually std::unique_ptr<Impl>, to a private implementation defined in the .cpp file. Private members can change without recompiling users, and the class's ABI stays stable.

What is CRTP?

The Curiously Recurring Template Pattern has a class derive from a template instantiated with itself: class Derived : public Base<Derived>. Base can call Derived's methods through static_cast, giving polymorphism with no virtual calls.

How do you write a thread-safe singleton in C++?

Return a reference to a function-local static: static Singleton& instance() { static Singleton s; return s; }. Since C++11 its initialisation is guaranteed to happen once, even with concurrent callers.

Why should a factory return std::unique_ptr?

It makes ownership explicit, frees the object automatically, and converts to shared_ptr if the caller needs shared ownership. Returning a raw pointer leaves who deletes it unclear.

What is type erasure?

Type erasure hides different concrete types behind one non-template interface, as std::function does for callables and std::any for values. It gives runtime polymorphism without requiring the types to share a base class.

What you can practice

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

More Fullstack interview questions

All interview questions