1.

When both the const and non-const version of functions are required?(a) Return value have to be different in const(b) Return value have to be same in const(c) Return values have to be ignored(d) Return values have to be suppressedI had been asked this question during an interview.My doubt stems from Constant Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (a) RETURN value have to be different in const

The explanation is: The return values can help to overload the functions. ALSO, this will allow us to USE a non-const function to be CALLED INSIDE both the const and non-const version of functions.



Discussion

No Comment Found

Related InterviewSolutions