Re: how to properly dereference STL list item

Discussion in 'C++' started by Howard, Jul 1, 2003.

  1. Howard

    Howard Guest

    "Danny Anderson" <> wrote in message
    news:p...
    > Hola, C++ folk!
    >
    >
    > I have a list of class objects, list<development> jobs.
    >
    > I previously didn't need the list after I went through it once, so I was
    > cycling through the list like this:
    >
    > development d;
    > while(!done)
    > {
    > d=job.front();
    > .
    > .
    > .
    > job.pop_front();
    > isJobDone(); //bool function to set exit condition
    > }
    >
    >
    > Now, I want to expand this program, so I am using iterators:
    >
    > list<development>::iterator itr;
    > for(itr=job.begin();itr!=job.end();++itr)
    > {
    > d= ????;
    > .
    > .
    > .
    > }
    >
    > What is the correct syntax to reach the values?
    >

    You already have the value...it's returned by the iterator itself. In other
    words, itr points to a development object. No need to assign it to another
    variable.

    -Howard
    Howard, Jul 1, 2003
    #1
    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. Jakob Bieling
    Replies:
    0
    Views:
    426
    Jakob Bieling
    Jul 1, 2003
  2. Gunnar G

    remove an item in a STL list

    Gunnar G, Feb 8, 2005, in forum: C++
    Replies:
    9
    Views:
    638
    Pete Becker
    Feb 9, 2005
  3. sam
    Replies:
    12
    Views:
    9,561
    Mike Wahler
    May 12, 2005
  4. Ratko
    Replies:
    7
    Views:
    278
    Reedick, Andrew
    Jul 17, 2008
  5. QUASAR
    Replies:
    6
    Views:
    410
    QUASAR
    Jan 17, 2004
Loading...

Share This Page