1.

What are const member functions?(a) Functions in which none of the data members can be changed in a program(b) Functions in which only static members can be changed(c) Functions which treat all the data members as constant and doesn’t allow changes(d) Functions which can change only the static membersI got this question in a job interview.This interesting question is from Types of Member Functions topic in chapter Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) FUNCTIONS which treat all the data members as constant and doesn’t ALLOW changes

The best I can explain: The CONST member functions are intended to keep the value of all the data members of a class same and doesn’t allow any changes on them. The data members are treated as constant data and any modification inside the const FUNCTION is restricted.



Discussion

No Comment Found

Related InterviewSolutions