Help with iterators

RiMZ
RiMZ used Ask the Experts™
on
Hi.  How do I access a member of an Associate object held in lista using an iterator like below?


    typedef list<Associate>::iterator iter;

 void display(list<Associate>& lista)
{
    int i=1;
    for (iter through=lista.begin(); through!=lista.end(); ++through)
     {
          cout << i << ". number is:" <<?????????<< "\t" << endl;
      }
}

I can't find anything in my books about it i've tried replaceing the ???? with lista.name.... lista(name).... lista(through.name) and several other things but I can't figure it out.

This is just an example i'm trying to get to work so that I can write other functions like search using iterators but I can't figure out how to access the memebers of the Associate held in list.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
cout << i << ". number is:" << (*iter).GetNumber() << "\t" << endl;

Assuming that GetNumber() is function of Associate class.
Commented:
Sorry, correction:

cout << i << ". number is:" << (*through).GetNumber() << "\t" << endl;

Commented:
Or somthing similar (and maybe more used) :

cout << i << ". number is:" << through->GetNumber() << "\t" << endl;

Always assuming GetnNumber is a member function of Associate as Alex said..
Older libraries only support AlexFM's approach.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial