Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


using 2d std::array


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 lride   Members   -  Reputation: 638

Like
0Likes
Like

Posted 09 December 2012 - 06:47 PM

How do you create 2d std::array?
Say I want to create a 2d int array with 10 rows and 5 columns
And how would you access each element?

It seems like it's different from c-style array
An invisible text.

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 10843

Like
1Likes
Like

Posted 09 December 2012 - 07:41 PM

You can just make a std::array of std::arrays. Ex: std::array<std::array<int, 5>, 10>.

#3 lride   Members   -  Reputation: 638

Like
1Likes
Like

Posted 09 December 2012 - 07:44 PM

You can just make a std::array of std::arrays. Ex: std::array<std::array<int, 5>, 10>.

5 is the row and 10 is the column?
So I can access each element by
array[row][column]?
An invisible text.

#4 SiCrane   Moderators   -  Reputation: 10843

Like
1Likes
Like

Posted 09 December 2012 - 07:54 PM

std::array<std::array<int, 5>, 10> gets you 10 std::array<int, 5>s, which in turn are 5 ints. So you can use array[0-9][0-4].




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS