+ 2
What does a 3D array look like?
I understand that 3D array would be declared as string 3DARR [x][y][z]; but who would the code look to initialize it?
4 ответов
+ 9
String 3DArr [x][y][z] = new String[x][y][z]{{{}}};
+ 9
Ok perhaps just String 3DArr [x][y][z] = {{{}}};
EDIT: how did I not see that *face palm*
+ 9
EDIT: Sample looks something like
int arr[2][2][2] = {{{1, 2}, {1, 2}}, {{1, 2}, {1, 2}}};
I went overboard with the first example there with 16 elements. :facepalm:
With this, accessing
arr[1][0][1] will return 2
arr[0][0][0] will return 1
arr[1][1][1] will return 2
and so on.
+ 5
@Yerucham... I looked into this earlier and remember there was special syntax.
Unfortunately your example doesn't seem to work here on gcc:
string threeDArr [1][1][1] = new string[1][1][1]{{{}}};
sorry, unimplemented: cannot initialize multi-dimensional array with intializer
@Dylan - I'm just noting this in case Yerucham has another idea; I'm only at the "poke it with a stick" stage of looking.