1

How would I use something like:

int array[][] = {{0,0,0},{1,0,0}};

...which is Java code in C++?

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

I'll make your answer the accepted one as it has more information. Thanks to both :)
3

You would do it like so:

int array[][3] = {{0,0,0},{1,0,0}};

Only the first dimension may be omitted.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.