Re: how can I loop a std::list ?
From: Siemel Naran (SiemelNaran_at_REMOVE.att.net)
Date: 08/12/04
- Next message: Siemel Naran: "Re: Productivity in programming of C++ programmers"
- Previous message: John Carson: "Re: [OT] struct problem"
- In reply to: David Ecker: "Re: how can I loop a std::list ?"
- Next in thread: Carlos Martinez Garcia: "Re: how can I loop a std::list ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 12 Aug 2004 16:41:23 GMT
"David Ecker" <david@familie-ecker.net> wrote in message news:D4GSc.2784
> Siemel Naran wrote:
> > Please be aware that the following does not work, and can you tell why?
> >
> > for(iteratorA=list.begin();iteratorA!=list.end();++iteratorA) {
> > if (*iteratorA == 3) list.erase(iteratorA);
> > }
>
> Of course, the iterator is invalid after the erase. It points to a delete
> item.
Right. So do you know how to fix it (assuming you don't want to use
list::remove or are implementing this function)?
- Next message: Siemel Naran: "Re: Productivity in programming of C++ programmers"
- Previous message: John Carson: "Re: [OT] struct problem"
- In reply to: David Ecker: "Re: how can I loop a std::list ?"
- Next in thread: Carlos Martinez Garcia: "Re: how can I loop a std::list ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|