Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

using 2d std::array

4: Adsense

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   

663
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.

#2 SiCrane   Moderators   

11761
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   

663
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   

11761
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.