Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

2d stl array

/*
std::array is 1-dimensional, there is no such thing as a 2-dimensional std::array.
You would simply have to use an inner std::array as the element type of an outer 
std::array, eg:
*/
#include <iostream>
#include <array>

int main(){
  std::array<std::array<int,5>,4> myarray;
  for (int i=0; i<5; i++){
    for (int j=0; j<10; j++){
      myarray[i].at(j) = j+1;    
    }
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #stl #array
ADD COMMENT
Topic
Name
5+7 =