C++ examples for Data Type:const
Attempting to modify data through a nonconstant pointer to constant data.
void f( const int * ); // prototype int main() /*www . j ava2 s . c o m*/ { int y; f( &y ); // f attempts illegal modification } // xPtr cannot modify the value of constant variable to which it points void f( const int *xPtr ) { // *xPtr = 100; // error: cannot modify a const object }