Thank you for your help.
Tobias
As a type in general, it's an array of pointers to a constant T. Try putting a name in it:
T const *x[];
and apply the usual rules: [] binds tighter than *, so it's an
array. Then the * means that its an array of pointers, and
finally, they all point to a constant T. (As usual, const
modifies whatever is to the left of it.)
As a parameter, of course, an array type is converted to a pointer type, so we end up with a pointer to a pointer to a constant T. This could also be written:
T const **
If you drop the const, you end up with:
T **
which is not the same thing as T const**
.
And the reason you can't pass a T**
or a 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; // Where does this write?
The fact that the declarations are written using [] is, in this case, misleading, since the rules for pointers to pointers still apply.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With