Reputation: 23
How would I use something like:
int array[][] = {{0,0,0},{1,0,0}};
...which is Java code in C++?
Upvotes: 1
Views: 109
Reputation: 236034
Like this:
int array[2][3] = {{0,0,0},{1,0,0}};
Or this, because the first dimension is optional:
int array[][3] = {{0,0,0},{1,0,0}};
And by the way, in Java the idiomatic way to declare the same array is this:
int[][] array = {{0,0,0},{1,0,0}}; // [][] goes before the variable name
Upvotes: 3
Reputation: 110668
You would do it like so:
int array[][3] = {{0,0,0},{1,0,0}};
Only the first dimension may be omitted.
Upvotes: 3