inta1=1;intb1=2;intc1=3;int*pointer=&a1;intconst*pointerToConst=&b1;int*constconstPointer=&c1;inta2=10;intb2=20;intc2=30;pointer=&a2;pointerToConst=&b2;//constPointer = &c2; // the pointer cannot be moved
*pointer+=100;//*pointerToConst += 100; // the pointed data cannot be changed
*constPointer+=100;cout<<"*pointer = "<<*pointer<<"\n"<<"*pointerToConst = "<<*pointerToConst<<"\n"<<"*constPointer = "<<*constPointer<<endl;
inta=0;intb=1;// An int that cannot be changed.
constintconstNumber_1=a;intconstconstNumber_2=a;//constNumber_1 = 10;
// A pointer that can be repointed to an int that cannot be changed.
constint*pointerToConst_1=&a;intconst*pointerToConst_2=&a;pointerToConst_1=&b;//*pointerToConst_1 = 10;
// A pointer that cannot be moved to an integer that may be changed.
int*constconstPointer=&a;//constPointer = &b;
*constPointer=10;// A pointer that cannot be moved to an integer that cannot be changed.
constint*constconstPointerToConst_1=&a;intconst*constconstPointerToConst_2=&a;//constPointerToConst_1 = &b;
//*constPointerToConst_1 = 10;
// Error, const applied to int twice.
// (warning C4114: same type qualifier used more than once).
constintconst*pointerToTwiceConst=&a;pointerToTwiceConst=&b;//*pointerToTwiceConst = 10;
// A pointer that may be repointed. It points to a pointer that cannot be moved to
// an int that may be modified.
int*pa=&a;int*const*pointerToConstPointer=&pa;int*pb=&b;pointerToConstPointer=&pb;//*pointerToConstPointer = pb;
**pointerToConstPointer=10;