1.

If a class implements some dynamic memory allocations and pointers then _____________(a) Copy constructor must be defined(b) Copy constructor must not be defined(c) Copy constructor can’t be defined(d) Copy constructor will not be usedI got this question in a national level competition.The origin of the question is Copy Constructor topic in portion Constructors and Destructors of Object Oriented Programming

Answer»

Correct CHOICE is (a) Copy constructor must be defined

The best explanation: In the case where DYNAMIC memory allocation is used, the copy constructor definition must be given. The IMPLICIT copy constructor is not capable of manipulating the dynamic memory and pointers. Explicit definition allows to manipulate the DATA as REQUIRED.



Discussion

No Comment Found

Related InterviewSolutions