3 ms·
The type of `new T[N]` is T. The type of `new T[10]` is also T. The type of `new T` is also T. Yes if you have a statically sized array you can make a pointer
by olliej 4y ago
The type of `new T[N]` is T. The type of `new T[10]` is also T. The type of `new T` is also T.
Yes if you have a statically sized array you can make a pointer to an array of that length, but those are generally not relevant outside of specific cases (arrays in structs or on the stack where the size impacts offsets in codegen). More over the desire of C and C++ to drop those annotations is such that even using your proposal of a pointer to an array rather than just an array, is of questionable value. Take an extension of your example:
int(*y)[3] = ...;
int(*y2)[3] = ...;
You can't do
*y2 = *y;
Because C doesn't let you assign arrays by value, even fixed size ones \o/