1.

Which is the correct syntax for defining a function which passes an object by reference?(a) className& functionName ( )(b) className* functionName( )(c) className-> functionName( )(d) &className functionName()This question was posed to me in an online interview.My question is from Returning Objects topic in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right answer is (a) className& functionName ( )

The best explanation: The function declaration must CONTAIN the CLASS name as return type. But, a & SYMBOL should be FOLLOWED by the class name. & INDICATES that the object being returned will be returned by reference.



Discussion

No Comment Found

Related InterviewSolutions