这是我的代码:
std::list<User>::iterator it;
while (it != allUsers.end())
{
if (it->getId() == userId)
{
allUsers.remove(*it);
return *it;
}
else
{
it++;
}
}
我得到的错误:列表迭代器与擦除不兼容 为什么?
答案 0 :(得分:2)
您必须使用erase()
而不是public void onRoutingFailure(RouteException e) {
if(e != null) {
Toast.makeText(this, "Error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}else {
Toast.makeText(this, "Something went wrong, Try again", Toast.LENGTH_SHORT).show();
}
}
来使用迭代器从列表中删除元素:
remove()