STL iterator delete problem
years ago carl report problem in chinaunix.net: bug of stl on hpux.when delete some element in the stl containers,not work.others ok.
now i encount the problem again,but not bug.and the solution:
for(iterator continue)
{
if(want to delete)
{
delete the pointer;
delete the element and move on the cursor;
}
else
{
increment
}
}
and use the r iterator also will be ok.just because when you delete the elemetn.so the iteraotr changed,then error occurs
[@more@]声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。