Re: how to properly dereference STL list item

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

  1. "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?



    d = *itr;

    Just like you dereference a pointer, you dereference the iterator, sort
    of ;o)

    hth
    --
    jb

    (replace y with x if you want to reply by e-mail)
     
    Jakob Bieling, 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. Howard
    Replies:
    0
    Views:
    404
    Howard
    Jul 1, 2003
  2. Gunnar G

    remove an item in a STL list

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

Share This Page