Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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: 633

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: 9626

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: 633

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: 9626

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