I would like to define int array in which first dimension is choosen dynamically but second is static --
something like int array[][8]
. Unfortunatelly I can not allocate such array dynamically. int ary[][8] = new int[11][8];
Produces error:
error: initializer fails to determine size of ‘array’
6 | int array[][8] = new int[11][8];
| ^~~~~~~~~~~~~~
2d.cpp:6:20: error: array must be initialized with a brace-enclosed initializer
or when I try following code:
int array[][8] = new int*[11];
array[0] = new int[8];
I get
2d2.cpp:6:22: error: initializer fails to determine size of ‘array’
6 | int array[][8] = new int*[11];
| ^~~~~~~~~~~~
2d2.cpp:6:22: error: array must be initialized with a brace-enclosed initializer
2d2.cpp:7:25: error: incompatible types in assignment of ‘int*’ to ‘int [8]’
7 | array[0] = new int[8];
Is that even possible in c++?