Would vector of vectors be contiguous?

Posted by user1150989 on Stack Overflow See other posts from Stack Overflow or by user1150989
Published on 2013-10-21T20:51:40Z Indexed on 2013/10/21 21:53 UTC
Read the original article Hit count: 154

Filed under:
|
|

I need to allocate a vector of rows where row contains a vector of rows. I know that a vector would be contiguous. I wanted to know whether a vector of vectors would also be contiguous. Example code is given below

vector<long> firstRow;

firstRow.push_back(0);

firstRow.push_back(1);

vector<long> secondRow;

secondRow.push_back(0);

secondRow.push_back(1); 

vector< vector < long> > data;

data.push_back(firstRow);

data.push_back(secondRow);

Would the sequence in memory be 0 1 0 1?

© Stack Overflow or respective owner

Related posts about c++

Related posts about vector