Continuing with the const correctness theme:
#include<iostream>
using namespace std;
int main()
{ int a = 34;
int b = 2009;
int *const x = &a; cout<<"*x(1) = "<<*x<<endl;
*x = 33;
cout<<"*x(2) = "<<*x<<endl;
const int *y;
y = &b;
cout<<"*y(1) = "<<*y<<endl; y = x; cout<<"*y(2) = "<<*y<<endl;
int c = 23456;
int const *z=&c;
cout<<"*z(1) = "<<*z<<endl; z = x; cout<<"*z(2) = "<<*z<<endl; const int i = 1111;
int const j = 4444; int *k = const_cast<int *>(&i);
cout<<"*k(1) = "<<*k<<endl;
*k = 5678;
cout<<"*k(2) = "<<*k<<endl;
cout<<"i = "<<i<<endl;
return 0;
}
The output is as follows:

It may be sometimes confusing to remember is the const is associated with the pointer or the variable. A simpler way to remember is that const is applied to whatever it is near. Another thing is that You have to read pointer declarations right-to-left. So:
- const Fred* p means "p points to a Fred that is const" — that is, the Fred object can't be changed via p.
- Fred* const p means "p is a const pointer to a Fred" — that is, you can change the Fred object via p, but you can't change the pointer p itself.
- const Fred* const p means "p is a const pointer to a const Fred" — that is, you can't change the pointer p itself, nor can you change the Fred object via p.