1
array<int,2>^ a = gcnew array<int,2>(5,5);
    for(int i=0; i<5; i++)
    {
        for(int j=0; j<5; j++)
        {
            a[i][j] = 0;
        }
    }

The above code is giving me the following two errors:

Error 1 error C3262: invalid array indexing: 1 dimension(s) specified for 2-dimensional 'cli::array ^'

Error 2 error C2109: subscript requires array or pointer type

Why is it so? :(

2
  • The correct tag is c++-cli, not cli. Please remember to review what the tag says it is when selecting. Commented Nov 25, 2013 at 18:19
  • @crashmstr: sorry i was new to this c++-cli. Commented Nov 25, 2013 at 18:29

2 Answers 2

3

Found the solution!

Instead of using:

a[i][j] = 0;

It should be like this:

a[i,j] = 0;
Sign up to request clarification or add additional context in comments.

1 Comment

Please check the time of my post and that of Vlad's ! He posted it 2mins after I had posted the solution. So did I have done something wrong..? :) BTW, thanks for the negative rep, just for posting the solution I found! :)
2

Use trhe following form of indexing

a[i, j] = 0;

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.