1.

In copy constructor definition, if non const values are accepted only ________(a) Only const objects will be accepted(b) Only non – const objects are accepted(c) Only const members will not get copied(d) Compiler generates an errorThe question was asked during an online interview.This intriguing question originated from Assigning Objects in portion Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

The correct answer is (B) Only NON – const objects are accepted

The best EXPLANATION: Only the non – const objects will be accepted by the compiler. If a const object is passed, the compiler produces an error. To REDUCE that, we use const ARGUMENT in definition, so that both const and non – const objects are accepted.



Discussion

No Comment Found

Related InterviewSolutions