const member function in C++

Like member functions and member function arguments, the objects of a class can also be declared as const. an object declared as const cannot be modified and hence, can invoke only const member functions as these functions ensure not to modify the object. 
Constant member functions are those functions which cannot change the values of the data members of their class. To make a member function constant, the keyword “const” is appended to the function prototype and also to the function definition header.
A const object can be created by prefixing the const keyword to the object declaration. Any attempt to change the data member of const objects results in a compile-time error. 
```
#include<iostream>
using namespace std;

class Demo
{
    int value;
public:
    Demo(int v = 0) {value = v;}
    void showMessage()
    {
        cout<<"showMessage() Function"<<endl;
    }
    void display() const
    {
        cout<<"display() Function"<<endl;
    }
};
int main()
{
   //Constant object are initialised at the time of declaration using constructor
    const Demo d1;
    //d1.showMessage();Error occurred if uncomment.
    d1.display();
    return(0);
}
```