Pushing an array into a vector.

Posted by Sunil on Stack Overflow See other posts from Stack Overflow or by Sunil
Published on 2010-12-27T20:22:44Z Indexed on 2010/12/27 20:54 UTC
Read the original article Hit count: 155

Filed under:
|

I've a 2d array, say A[2][3]={{1,2,3},{4,5,6}}; and I want to push it into a 2D vector(vector of vectors). I know you can use two for loops to push the elements one by on on to the first vector and then push that into the another vector which makes it 2d vector but I was wondering if there is any way in C++ to do this in a single loop. For example I want to do something like this:

myvector.pushback(A[1]+3); // where 3 is the size or number of columns in the array.

I understand this is not a correct code but I put this just for understanding purpose. Thanks

© Stack Overflow or respective owner

Related posts about c++

Related posts about vector