Sign in to follow this  
lride

using 2d std::array

Recommended Posts

lride    674
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

Share this post


Link to post
Share on other sites
lride    674
[quote name='SiCrane' timestamp='1355103680' post='5008940']
You can just make a std::array of std::arrays. Ex: std::array<std::array<int, 5>, 10>.
[/quote]
5 is the row and 10 is the column?
So I can access each element by
array[row][column]?

Share this post


Link to post
Share on other sites
SiCrane    11839
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].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this