const keyword in C++

Pointer to constant can be declared in following two ways. We can change the pointer to point to any other integer variable, but cannot change the value of the object (entity) pointed using pointer ptr.
```
const int *ptr;
int const *ptr;
```
Constant pointer to an integer variable, means we can change the value of object pointed by pointer, but cannot change the pointer to point another variable. 
```
int * const ptr;
```
Constant pointer to a constant variable which means we cannot change value pointed by the pointer as well as we cannot point the pointer to other variables. Let us see with an example. 
```
int const * const ptr;
```
Below is an example, 
```
#include <iostream>
  
int main(void)
{
   int i = 10;
   int j = 20;

   const int *p1 = &i;   // pointer to const value
   int const *p2 = &i;   // pointer to const value
   int *const p3 = &i;   
  
   //*p1 = 20; // error, cannot change 
   //*p2 = 20; // error, cannot change 
      
   *p3 = 20; 
   //p3 = &j;  // error, cannot change
       
   return 0;
}
```
A const object cannot call a non-const function. 
In C++ any variable declared as constant needs to be initialized at the time of declaration.