Modern C++ interview questions

15 real Modern C++ questions from the C++ bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is constexpr?

Mid
  1. A.a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  2. B.a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  3. C.a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  4. D.a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
Reveal the answer + AI explanation — free account

2. Which term means: "a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions"?

Mid
  1. A.constexpr
  2. B.std::optional
  3. C.std::span
  4. D.Structured bindings
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Mid
  1. A.constexpr — a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  2. B.constexpr — a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  3. C.constexpr — a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
  4. D.constexpr — a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
Reveal the answer + AI explanation — free account

4. What is Structured bindings?

Mid
  1. A.a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  2. B.a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers
  3. C.a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  4. D.a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. A.Structured bindings — a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  2. B.Structured bindings — a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  3. C.Structured bindings — a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  4. D.Structured bindings — a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
Reveal the answer + AI explanation — free account

7. What is std::optional?

Mid
  1. A.a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers
  2. B.a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  3. C.a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  4. D.a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
Reveal the answer + AI explanation — free account

8. Which term means: "a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers"?

Mid
  1. A.Structured bindings
  2. B.std::optional
  3. C.std::span
  4. D.constexpr
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Mid
  1. A.std::optional — a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
  2. B.std::optional — a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
  3. C.std::optional — a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers
  4. D.std::optional — a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
Reveal the answer + AI explanation — free account

10. What is std::variant?

Senior
  1. A.a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  2. B.a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers
  3. C.a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  4. D.a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Senior
  1. A.std::variant — a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  2. B.std::variant — a wrapper that either contains a value or is empty, expressing a possibly-absent result without resorting to sentinels or pointers
  3. C.std::variant — a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
  4. D.std::variant — a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
Reveal the answer + AI explanation — free account

13. What is std::span?

Senior
  1. A.a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
  2. B.a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  3. C.a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  4. D.a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
Reveal the answer + AI explanation — free account

14. Which term means: "a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data"?

Senior
  1. A.std::span
  2. B.Structured bindings
  3. C.constexpr
  4. D.std::optional
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Senior
  1. A.std::span — a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement
  2. B.std::span — a non-owning lightweight view over a contiguous sequence of elements, carrying a pointer and length without copying the data
  3. C.std::span — a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation
  4. D.std::span — a specifier marking a function or variable as evaluable at compile time, allowing its result to be used in constant expressions
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Modern C++ free