Iterator to list of iterators

Discussion in 'C++' started by Daniel Marques, Sep 14, 2006.

  1. 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
     
    Daniel Marques, Sep 14, 2006
    #1
    1. Advertising

  2. Daniel Marques

    Mark P Guest

    Daniel Marques wrote:
    > 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
     
    Mark P, Sep 14, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcin Kaliciñski

    Iterators and reverse iterators

    Marcin Kaliciñski, May 8, 2005, in forum: C++
    Replies:
    1
    Views:
    493
    Kai-Uwe Bux
    May 8, 2005
  2. Replies:
    6
    Views:
    657
    Jim Langston
    Oct 30, 2005
  3. Mark Stijnman
    Replies:
    5
    Views:
    512
    Mark Stijnman
    Jan 28, 2006
  4. David Bilsby
    Replies:
    5
    Views:
    2,053
    David Bilsby
    Oct 9, 2007
  5. , India
    Replies:
    10
    Views:
    1,085
    James Kanze
    Aug 8, 2009
Loading...

Share This Page