a question regarding lists, pointers and iterators

Hello everyone!

In my code, I have the following list:

list <list <cg_node *> > where cg_node is a class of mine. So, to simpify, there is a list of lists of pointers to cg_node. I use iterators to access the lists like this:

1
2
3
4
5
6
7
8
9
10
11
12
list < list <cg_node *> > big_list;

list < list <cg_node *> >::iterator it_big_list;

for (it_big_list=big_list.begin();it_big_list!=big_list.end();it_big_list++)
{
    list <cg_node *>::iterator it_list;

    for (it_list=(*it_big_list).begin();it_list!=(*it_big_list).end();it_list++)
        printf("\n num = %d", (*it_list)->number());
    printf("\n");
}


where number() is a cg_node method that returns a number.

Is it correct the way I'm accessing the data, or am I doing something wrong?

Thanks to everyone in advance!

Regards,
Dimitris
Last edited on
Topic archived. No new replies allowed.