List Iterator Remove()

后端 未结 4 594
天涯浪人
天涯浪人 2020-12-08 06:19

I have a list iterator that goes through a list and removes all the even numbers. I can use the list iterator to print out the numbers fine but I cannot use the list\'s remo

4条回答
  •  独厮守ぢ
    2020-12-08 06:30

    You can't use an iterator after you delete the element it referred to.

    However, list iterators which refer to non-deleted items after a remove() should remain valid.

提交回复
热议问题