i am trying to create a vector of int 2D array in c++ but my following code has some errors that i can't realize why?!
vector< int[2][2] > vec;
int a[2][2];
vec.push_back(a);
i don't want to use int ** int my vetor (and create a 2D array using new)
and i know each of 2D arrays has just 2 col and row (the size is static)
so is there any way to implement that vector or not?
and i also try to push_back just an array to vecotr and it wasn't successful too! why?
vector< int[2] > vec;
int a[2];
vec.push_back(a);
thanks in advance
Native arrays are not copyable, moveable or assignable, so they cannot be stored in a standard container.
However, the wrapper std::array<T,N> is, so std::vector<std::array<std::array<int, 2>, 2> > is one way to do what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With