Lets say i have vector of vectors
vector< vector<int> > bigTable;
vector<int> data;
data.resize(2);
fingertable.resize(5,data);
How do i insert a vector in?
vector<int> newData;
newData.resize(2);
newData.push_back(123);
newData.push_back(456);
When i do the following, the data in the bigTable vector is still 0.
bigTable.push_back(newData);
cout << bigTable[0][0]; // this will produce an output of 0
I think you misunderstand what
resizedoes (perhaps you’re thinking ofreserve?). After your second code snippet,newDatawill contain 4 elements:0,0,123,456.