Created
May 12, 2013 17:30
-
-
Save fpersson/5564326 to your computer and use it in GitHub Desktop.
2D array in C++ 11 with std::array (note the brackets).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <array> | |
int main(){ | |
//col, row | |
std::array<std::array<int, 10>, 10> mymap{{ | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}}, | |
{{1,2,3,4,5,6,7,8,9,0}} | |
}}; | |
for(auto& col: mymap){ | |
for(auto& row: col){ | |
std::cout << row << " "; | |
} | |
std::cout << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment