4 ms·
I believe the distinction they’re making is that there is actually no guarantee that the value pointed to by x will remain constant. All this tells you is that
by mikeash 7y ago
I believe the distinction they’re making is that there is actually no guarantee that the value pointed to by x will remain constant. All this tells you is that you’re not allowed to use x to make the modification.
Consider:
int foo = 42;
const int *x = &foo;
foo = 43;
- dmitrygr 7y agoRestrict keyword does do that if you wish to say that to the compiler. It tells it that no parameters point to the same memory. So if you won't change things via x, *x won't change.