1.

What is the syntax of copy constructor?(a) classname (classname &obj){ /*constructor definition*/ }(b) classname (cont classname obj){ /*constructor definition*/ }(c) classname (cont classname &obj){ /*constructor definition*/ }(d) classname (cont &obj){ /*constructor definition*/ }This question was posed to me during an interview.This is a very interesting question from Copy Constructor in portion Constructors and Destructors of Object Oriented Programming

Answer»

The correct choice is (c) CLASSNAME (cont classname &obj){ /*constructor definition*/ }

To explain: The syntax must contain the class name first, followed by the classname as type and &object within PARENTHESIS. Then comes the constructor BODY. The definition can be given as PER requirements.



Discussion

No Comment Found

Related InterviewSolutions