1.

If an object is being returned by value then __________________________(a) Its member values are made constant(b) Its member values have to be copied individually(c) Its member values are not used(d) Its member values are copied using copy constructorI had been asked this question during a job interview.I'm obligated to ask this question of Returning Objects topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right answer is (d) Its member values are copied using copy CONSTRUCTOR

The best I can explain: When an object is returned by value, it will be returned to another object or will be DIRECTLY USED. Still in all the conditions the copy constructor will be used to copy all the values from the TEMPORARY object that gets created.



Discussion

No Comment Found

Related InterviewSolutions