The answer here says:
From n2798 (draft of C++0x): The elements of a vector are stored contiguously, meaning that if v is a vector where T is some type other than bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().
This program works:
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
int main(){
int k;
cin >> k; cout << endl << "k = " << k << endl;
ostream_iterator<int> oi(cout, " ");
vector<vector<int> > vpi;
while(k--)
{
vpi.push_back(vector<int>(istream_iterator<int>(cin), istream_iterator<int>()));
cin.clear();
cout<<"k = "<< k <<endl;
copy(vpi[vpi.size()-1].begin(), vpi[vpi.size()-1].end(), oi);
cout<<endl;
}
}
How can a vector store vectors contiguously, when the elements of a vector must have equal size and the size of vectors to be stored is not known in advance?
I apologize if this has been asked before, I could not find it, if this is the case just drop me a link, please.