首页 > 解决方案 > 读取访问冲突。_Mycont 为 nullptr

问题描述

我正在尝试使用迭代器删除向量 STL 中的记录。但是抛出异常。

for (it = sp.begin(); it != sp.end(); ++it)
    {
        if (it->Id() == d)
            {
                sp.erase(it); //Where error starts
            }
    }

到达这些代码后,它会弹出错误异常

_STL_VERIFY(_Ptr < _Mycont->_Mylast, "can't increment vector iterator past end");

抛出异常:读取访问冲突。_Mycont 为 nullptr。

标签: c++visual-studiovectorstliterator

解决方案


推荐阅读