C++ examples for Data Type:const
Attempting to modify a constant pointer to nonconstant data.
int main() //from w w w. j a v a 2 s . c om { int x, y; int * const ptr = &x; // const pointer must be initialized *ptr = 7; // allowed: *ptr is not const //ptr = &y; // error: ptr is const; cannot assign to it a new address }