Iterator to list of iterators

D

Daniel Marques

I'm having trouble to access a list of iterators to other list. See the
sample code below for more clarification:

class A {
public:
A() {}
int f() { }
};

class B {
public:
list<list<A>::iterator> lList;
};


To run through the list I can create an iterator to this list. But I
need to access the information contained in these iterators.
list<list<A>::iterator>::iterator it;
it = lList.begin();
Now I have a iterator to an iterator of a list of the class A type. How
can I do to get access to the member f() using the iterator it?

Thanks in Advance,
Daniel Marques
 
M

Mark P

Daniel said:
I'm having trouble to access a list of iterators to other list. See the
sample code below for more clarification:

class A {
public:
A() {}
int f() { }
};

class B {
public:
list<list<A>::iterator> lList;
};


To run through the list I can create an iterator to this list. But I
need to access the information contained in these iterators.
list<list<A>::iterator>::iterator it;
it = lList.begin();
Now I have a iterator to an iterator of a list of the class A type. How
can I do to get access to the member f() using the iterator it?

*it is of type list<A>::iterator
**it is of type A
(**it).f() is what you want
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top