1.

If object is passed by value ______________(a) Copy constructor is used to copy the values into another object in the function(b) Copy constructor is used to copy the values into temporary object(c) Reference to the object is used to access the values of the object(d) Reference to the object is used to created new object in its placeI have been asked this question during an interview.My question is from Passing Object to Functions topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Correct option is (a) Copy constructor is USED to copy the VALUES into another OBJECT in the function

Explanation: The copy constructor is used. This constructor is used to copy the values into a new object which will contain all the values same as that of the object being passed but any CHANGES made to the newly created object will not affect the ORIGINAL object.



Discussion

No Comment Found

Related InterviewSolutions