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:
xdefault ctor called,func(y(x))called:y(x)ctor explicitly called create y objectx.
compilation of code depends (among other things) on x , y constructors, ex.:
- adding private default ctor
xprevents code compilation, - adding private copy ctor
yprevents code compilation.
Comments
Post a Comment