using 2d std::array

Started by
2 comments, last by SiCrane 11 years, 4 months ago
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.
Advertisement
You can just make a std::array of std::arrays. Ex: std::array<std::array<int, 5>, 10>.

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

This topic is closed to new replies.

Advertisement