How would I access a list inside a list? Say for...
Code:list<int> inside;
list<list<int>* > outside;
list<list<int> *>::iterator outIter;
list<int>:: iterator inIter;
outside.push_front(&inside);
outIter = outside.begin();
inIter = ???;
Printable View
How would I access a list inside a list? Say for...
Code:list<int> inside;
list<list<int>* > outside;
list<list<int> *>::iterator outIter;
list<int>:: iterator inIter;
outside.push_front(&inside);
outIter = outside.begin();
inIter = ???;
Is there a reason your inner list is a pointer? Why not just a list of lists?
As is, you'd need to dereference the outIter iterator, which would give you a list pointer. Then you'd ned to dereference the list pointer and call the member function begin() to get an iterator pointing at the first int. So:Of course, in the above code, you would never want to use inIter, because the inside list is empty.Code:inIter = (*outIter)->begin();
If you got rid of the pointer, it would look like this:Code:list<int> inside;
list<list<int> > outside;
list<list<int> >::iterator outIter;
list<int>::iterator inIter;
outside.push_front(inside); // note that a copy is pushed on to the list
outIter = outside.begin();
inIter = outIter->begin();
Thanks, was using pointer just becuase thats the way I had a vector of lists set up before. Just wanted to pick up the concept of how to work a list of list and wasn't sure how.