/* File to show compound STL containers. */ #include #include #include #include #include using namespace std; void main(){ vector > vl; srand(static_cast(time(0))); int numlists = rand()%10+1; list li; // init lists for(int i = 0; i < numlists; i++){ // shoot self in foot - create memory leak //vl.push_back(*(new list())); vl.push_back(li);// push a copy of li on the vector } // load lists for(int j = 0; j < static_cast(vl.size()); j++){ int numchain = rand()%5+1; for(int k = 0; k < numchain; k++){ vl[j].push_back(rand()%100); } } vector >::iterator ivl; list::iterator il; for(ivl = vl.begin(); ivl != vl.end(); ivl++){ for(il = (*ivl).begin(); il != (*ivl).end(); il++){ cout << *il << " "; } cout << endl; } }