Interview Q&A · C++ · 14 questions in this topic

Modern C++ Features — C++ Interview Q&A

All C++ topics

What modern C++ actually changed — auto, move, smart pointers, constexpr, lambdas, concepts, ranges and modules. Part of Modern C++ (11 to 23) · 213 questions in the C++ bank.

What did C++11 change and why does every interview ask about it?

Answer

C++11 was the language rebirth: auto, range-for, lambdas, rvalue references/move semantics, smart pointers, nullptr, constexpr, static_assert, threading (thread/mutex/atomic/future), unordered containers, and chrono/regex. It turned C++98 style (manual memory, functors, NULL) into modern style (ownership types, lambdas, deterministic safety).

Every later standard builds on it, so C++11 fluency is the baseline expectation.

Key points

  1. 1Types — auto, nullptr, strongly-typed enums, static_assert.
  2. 2Ownership — unique_ptr/shared_ptr, move semantics.
  3. 3Genericity — lambdas, range-for, variadics, constexpr.
  4. 4Concurrency — threads, mutexes, atomics, futures in the standard.

Example

Example.cppcpp
auto v = std::vector<int>{1, 2, 3};
for (const auto& x : v) { /* range-for (C++11) */ }

💡 Name one feature from each bucket (types, ownership, genericity, concurrency) to show breadth.

What did C++14 and C++17 each add?

Answer

C++14 completed C++11: generic lambdas (auto params), return-type deduction, digit separators, make_unique, shared timed mutexes. C++17 was the big productivity release: structured bindings, if-init statements, constexpr if, fold expressions, string_view, optional/variant/any, parallel algorithms, filesystem, hardware interference sizes, and inline variables.

Interview shorthand: 14 finished 11, 17 made daily code cleaner and safer.

Example

Example.cppcpp
std::map<int, std::string> m{{1, "a"}};
if (auto it = m.find(1); it != m.end()) { /* if-init (C++17) */ }
auto [k, v] = *it; // structured binding (C++17)

What did C++20 and C++23 add?

Answer

C++20: concepts, ranges/views, coroutines, modules, constexpr expansion (vector/string), three-way comparison (<=>), designated initializers, bit_cast, jthread/stop_token, calendars/timezones, and formatting groundwork. C++23: std::expected, std::print, ranges extensions (zip/views), flat containers, multidimensional span, stacktrace, and constexpr hardening.

Practical interview take: concepts plus ranges change how generic code is written; modules change how it is built.

Example

Example.cppcpp
#include <compare>
struct Point { int x, y; auto operator<=>(const Point&) const = default; };

💡 Concepts, ranges, coroutines, modules — those four carry the C++20 answer.

Recommended resourcesAffiliate links · may earn us a commission

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits