I’ve known that const qualifier only affects an object but not it’s type:
For example:
// Only the elements of an array are constant not the array itself
const int a[5];
Suppose if I had:
float *const p1; // 1
float const *p2; // 2
In the first case above, does it mean that pointer type is constant and not the object p1? How can this be when the types aren’t allowed to be qualified?
Means that the pointer
p1is constant and it cannot(rather should not) point to another address.It is not the pointer type that is constant but the instance of this type which is
p1that is contant.Use the Clockwise spiral rule to understand this better.
This is not correct. In fact, qualifier is a short form for type qualifier(§6.7.3)