Modern C++ interview questions

15 Modern C++ questions from the C++ bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.

Free to start: the 2-minute IT readiness check — six questions and a result.

Take the free IT readiness check

or take a mock interview set up for this area

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

5. Which term means: "a C++17 declaration that unpacks a tuple, pair, array, or struct into several named variables in one statement"?

Mid
  1. A.constexpr
  2. B.Structured bindings
  3. C.std::optional
  4. D.std::variant

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

11. Which term means: "a type-safe tagged union holding exactly one value from a fixed set of alternative types, accessed via visitation"?

Senior
  1. A.Structured bindings
  2. B.std::variant
  3. C.std::optional
  4. D.std::span

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

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

Answer + AI explanation with Pro

Free to start

Start with a free readiness check

Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Modern C++ question come with Pro.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers