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
using 2d std::array
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]?
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
Popular Topics
Advertisement