Reputation: 1336
Consider the MNWE:
enum T {VALUE};
int main() {
T T_arr[8][8];
T** T_arr_ptr = T_arr;
}
Now this does not compile, saying
error: cannot convert
T(*)[8]
toT**
in initialization
Without using auto
, what would be the correct type for this pointer?
Upvotes: 1
Views: 417
Reputation: 106012
2D array names decays to pointer to first row of the array and hence it is of type pointer to array. Here T_arr
is of type T(*)[8]
after decay.
Change
T** T_arr_ptr = T_arr;
to
T (*T_arr_ptr)[8] = T_arr;
Upvotes: 1