/** Attempting to modify a constant pointer to non-constant data. */ #include using namespace std; int main() { int x = 2, y = 5; int *const myPtr = &x; // constant pointer to a (non-constant) int // The data pointed to by myPtr can be // modified through myPtr, but myPtr must // always point to the same memory location. *myPtr = 99; // change value stored in x to 99 myPtr = &y; // syntax error!! can't point to a different int cout << *myPtr << endl; return 0; }