0

so ... i'm kinda new to these STL ...
i wanna make a list of lists ...
after spending some time to teach myself how to make a list of char I went one step further with a project I have to accomplish ...
so the thing is that i need a list (the list)in which each element will be a list of char(the sublist) .
I am thinking that by using this, each node of the list will have the root of it's sublist ( is that right ? )
And another thing ... how can i add more info to each node of the list(not the sublist), an char or int ... doesnt quite mather ... just the fact that to have more than a sublist in each node.
Is that possible ?
I tried something like this using only int-s . And i came across the problem of accesing the nodes of the list ... such as :

list<int> mylist;
list< list<int> > lista;
// adding elements to mylist ... 
lista.push_back(mylist);
//this works(to my amazement)

How can i step through "lista" (in case i put another list in there besides "mylist") and through mylist(which is now in "lista") so that i can access the elements i added ????
Thanks

2
Contributors
1
Reply
3
Views
9 Years
Discussion Span
Last Post by Ancient Dragon
0

you can use an iterator

list<int>::iterator it;
for(it = mylist.begin(); it != mylist.end(); it++)
{
    list<int>& sublist = *it;
    // blabla
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.