c++ - Compilation and execution when code is not dislosed; use of ellipsis in code -


in interview asked following question

given code fragments below, ellipsis (…) represents code has not been disclosed you:

class x { … };  class y { public: explicit y(const x& x); … };  

what can compilation , execution of each of following statements? describe each of operations occur code executes.

y func(y y) { … } x x; y y = func(y(x)); 

i not understand question hence not able answer. if 1 explain me answer expected of me or share link can go through, nice. many thanks.

perhaps ... means there code, affect compilation , execution of code?

what happening in code:

  • x default ctor called,
  • func(y(x)) called: y(x) ctor explicitly called create y object x.

compilation of code depends (among other things) on x , y constructors, ex.:

  • adding private default ctor x prevents code compilation,
  • adding private copy ctor y prevents code compilation.

Comments