nested lists, how to insert into a specific list

hi,
I have a structure
list<list<int> > mylist;
and an int that tells me into which outer list I should insert some other value.
e.g.: int i = 3;
now, if I want to push_back something in the i-th list, how would I do this?
something like
mylist[i]->push_back(100);

how do I write this so it actually works?
If you need to access elements by index you should consider another container. With a vector your code would work
1
2
3
vector<list<int> > mylist;
int i = 3;
mylist[i]->push_back(100);
Last edited on
thanks for your answer, Peter87!
I'd prefer vectors, too. but the lists are given and I'm supposed to work on them.

I thought about the insert method, but I don't know how to do the push_back then...
something like this:
mylist.insert(i, i.push_back(100));


any ideas?
In that case you need to use iterators
ok thanks, it's working now.
Topic archived. No new replies allowed.