DEV Community

Discussion on: C++ Common Interview Questions

Collapse
 
jeikabu profile image
jeikabu • Edited

I've taken (or written) C++ interview tests on and off for nigh 20 years and this feels like it's from 2000-ish. Actually, I just took one last month. The problems you'll run into vary widely depending on the level of the position and the target industry, but I usually run into most of the following:

  • Basics: sort a thing, reverse a string, write some trivial function, etc.
  • Design a class: either something generic like a string/stack or specific to a particular problem.
  • Template "shenanigans" (meta-programming): compile-time evaluation of something, or type-specific implementations.
  • Performance: looking for more in-depth knowledge about compilers and optimisation, SIMD, STL container big-O behaviour, or the like.
  • Memory: solve the memory leak or use smart pointers (including weak to avoid a cycle).
  • Virtual functions: specifically virtual destructor, or how vtables are commonly used.

In general, I'd stick to C++11/14 as employers I've seen have yet to widely embrace 17/20.

As someone whose written tests my personal favourite questions:

  • Show mastery of pointers
  • Trick candidates into returning a reference to a local
  • Memory leaks, memory leaks, memory leaks
Collapse
 
komalsingh1 profile image
Komal Singh

Thanks @jeikabu These are a great set of questions. I will cover these in the next blog. Thanks a lot!