1.

Which is the correct condition on const member functions?(a) Const member functions can’t call non-const member functions(b) Const member functions can’t call any other function(c) Const member functions can call only the functions which are neither const nor non-const(d) Const member functions can call only data members of call not member functionsI had been asked this question in homework.My question is taken from Constant Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Right answer is (a) CONST member FUNCTIONS can’t CALL non-const member functions

Best explanation: The const member functions are RESTRICTED to call any other non-const member functions. This is to ensure that the const FUNCTION doesn’t have any code that might modify the calling object.



Discussion

No Comment Found

Related InterviewSolutions