数据放在一个嵌套的vector里,我需要找到内层vector的特定元素然后删掉。但是我发现没有真的删掉,还是能访问到。为什么呢
bool LayerDic::remove(CString IdCStr)
{
vector<vector<Data>>::iterator group2 = resDataGroup.begin();
while ((group2) != resDataGroup.end()) {
vector<Data>::iterator it = (*group2).begin();
while ((it) != (*group2).end()) {
if (it->getIdCStr().Compare(IdCStr) == 0)
{
(*group2).erase(it);
temp();//为了验证是否真的删除
return true;
}
}
}
return false;
}
void LayerDic::temp()
{
vector<vector<Data>>::iterator group2 = resDataGroup.begin();
while ((group2) != resDataGroup.end())
{
vector<Data>::iterator it = (*group2).begin();
while ((it) != (*group2).end()) {
CString cs = it->getIdCStr();
it++;
}
group2++;
}
}