Logo

Question preview

Copy constructor, maybe.

What this preview is

About this preview

Copy constructor, maybe. is a medium quant interview question on language knowledge in Cpp.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

What this C++ copy-constructor question tests

This is a medium-difficulty C++ language-knowledge question that probes your understanding of copy semantics, object lifecycle, and compiler-generated special member functions. It rewards careful reading of code flow and knowledge of when and how the copy constructor is invoked.

To answer it, you need to trace through object construction and assignment, predict which constructors or operators are called at each step, and understand the implications for the program's output. The question is titled suggestively—the answer hinges on whether a copy constructor is actually being used, when you might expect one to be, or whether the compiler optimises it away entirely.

  • Copy constructor vs. copy assignment operator
  • Return value optimisation (RVO) and elision
  • Implicit vs. explicit construction
  • Compiler-generated vs. user-defined special members