Skip to content

Instantly share code, notes, and snippets.

@tejainece
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save tejainece/69f81a59b94185e273d9 to your computer and use it in GitHub Desktop.

Select an option

Save tejainece/69f81a59b94185e273d9 to your computer and use it in GitHub Desktop.
Vector of arrays in C++
void main() {
int a0[4] = {0, 1, 2};
int a1[4] = a0;
}
#include <vector>
#include <array>
#include <iostream>
using namespace std;
int main() {
vector<std::array<int, 3>> vec;
array<int, 3> a0 { {0, 1, 2} };
array<int, 3> a1 { {3, 4, 5} };
array<int, 3> a2 { {6, 7, 8} };
vec.push_back(a0);
vec.push_back(a1);
vec.push_back(a2);
for(array<int, 3> i : vec) {
cout << i[0] << " " << i[1] << " " << i[2] << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment