Why is this vector iterator not incrementable?

前端 未结 8 1269
没有蜡笔的小新
没有蜡笔的小新 2020-12-13 10:41

I\'m trying to delete the vector\'s content and I\'m getting an error - vector iterator is not incrementable, why is that?

This is my destructor:

C         


        
8条回答
  •  醉话见心
    2020-12-13 10:46

    If you are trying to free the data in the vector, do this:

    for (std::vector::iterator it = v.begin(), e = b.end(); it != e; ++it) 
        delete *it;
    

提交回复
热议问题