Take this example:
int main()
{
const char* what = "Is This";
what = "Interesting";
cout << *what;
what[3] = 'a'; // Sytax Error: expression must be a modifiable lvalue
cout << *what;
return 0;
}
So I declare what
as const char*
, and I was able to reassign it another value (actual data in the memory - not the memory address itself).
But then, it tells me that I can't change the character that is on the 4th position!
Why is that?