As a type in general, it is an array of pointers to the constant T. Try putting the name in it:
T const *x[];
and apply the usual rules: [] binds tighter than *, therefore an array. Then * means that its array of pointers, and finally, they all point to a constant T. (As usual, const
changes everything that is to its left.)
As a parameter, of course, the type of the array is converted to the type of the pointer, so we get a pointer to a pointer to the constant T. This can also be written:
T const **
If you release const, you will get:
T **
this is not the same as T const**
.
And the reason you cannot pass T**
or T*[]
to the first form is to prevent things like:
void f(int const* p1[]; int const* p2) { p1[0] = *p2; } int const x = 10; int* px[1]; f(px, &x); *px[0] = 20;
The fact that declarations are written using [] is misleading in this case because the rules for pointers to pointers apply.
source share