1.

Non-const functions _______________________(a) Can be called only from non-const object(b) Can be called only from const object(c) Can be called both by const and non-const object(d) Can’t be called with objectThis question was addressed to me in a national level competition.My doubt is from Constant Member Functions topic in section Member Functions & its Types of Object Oriented Programming

Answer»

Correct option is (a) Can be called only from non-const object

The best I can explain: The non-const functions are able to modify the values of object which called the function. So only the non-const functions can be called. If const object is used then the COMPILER PRODUCES an error as the const object is being GIVEN to a function which can modify its values.



Discussion

No Comment Found

Related InterviewSolutions