The statement const int* p = &a;
gives a pointer to a fixed value. While p
itself can be assigned to a different address (e.g. p = &b;
), we cannot change the dereferenced value (e.g. *p = 100;
gives a compile error).
I get that.
How can I define a pointer with a fixed address in that it cannot be reassigned? I mean if p2 = &a;
then p2 = &b;
should give a compile error.