Yes, this is a constant pointer to the constant T
Ie, you can neither change the pointer, nor what it points to.
const T*
forbid you to change everything that the pointer indicates, but allows you (within the language) to check the value in *(foo+1)
and *(foo-1)
. Use this form when you pass pointers to immutable arrays (for example, the C string you only have to read).
T * const
means that you can change the value of T
pointed to by foo
, but you cannot change the pointer itself; therefore you cannot say foo++; (*foo)++
foo++; (*foo)++
, because the first statement will increment (change) the pointer.
T *
will give you complete freedom: you get a pointer to an array, and you can check and modify any member of this array.
source share