Many materials mention that
const int *p
is a pointer to a const int.
I really don't think so and don't get this point because const int *p
just means that:
the value of the object p point to cannot be changed by dereferencing p.
It does not mean:
the object p points to need to be a const.
Example:
int a = 5;
const int *p = &a;
This code is totally valid and we don't need const int a = 5
So Why that wrong explanation is used widely?