What are Const Member Functions in C++ ?

 
 

There can be two cases in which a member function can be declared as a const function: whenever the member function wants to guarantee that it won't make any changes to its this object or whenever a caller needs to invoke the member function via a reference-to-const or pointer-to-const. The compiler wont allow a const member function to change *this or to invoke a non-const member function for this object. E.g. int getCount() const;int getCount () const{ //function definition}