1.

If programmer doesn’t define any copy assignment operator then ____________________(a) Compiler gives an error(b) Program fails at run time(c) Compiler gives an implicit definition(d) Compiler can’t copy the member valuesI had been asked this question by my school principal while I was bunking the class.This interesting question is from Assigning Objects in chapter Assigning Object, Pointer to Objects, Passing and Returning Object of Object Oriented Programming

Answer»

Right answer is (c) Compiler gives an implicit definition

The explanation is: While DEFINING a COPY constructor, we use REFERENCE const parameter, those are used for the assignment. The assignment operator may or may not be defined by the programmer, if not, compiler implicitly defines member WISE copy assignment operator.



Discussion

No Comment Found

Related InterviewSolutions