C++ 向量抛出a";访问冲突读取位置“;例外。C++;。VS 2012

C++ 向量抛出a";访问冲突读取位置“;例外。C++;。VS 2012,c++,exception,vector,visual-studio-2012,C++,Exception,Vector,Visual Studio 2012,所讨论的向量声明如下: vector<int> lowerList; 然后使用0到8之间的数字填充向量: lowerList.push_back(); 随机选择其中一个矢量元素,并使用以下方法移动到: if(!lowerList.empty()){ int element = rand()%lowerList.size(); int lowerIndex = lowerList.at(element); MoveTo(lowerIndex, curr

所讨论的向量声明如下:

vector<int> lowerList;
然后使用0到8之间的数字填充向量:

lowerList.push_back();
随机选择其中一个矢量元素,并使用以下方法移动到:

if(!lowerList.empty()){

    int element = rand()%lowerList.size();

    int lowerIndex = lowerList.at(element);

    MoveTo(lowerIndex, currentX, currentZ);
}
唯一一次访问向量的时候是这样的:

if(lowerList.empty()){
    return true;
}else
    return false;
我收到一个运行时错误,它说:

Engine.exe中0x00C702C8处未处理的异常:0xC0000005:访问冲突读取位置0x0870249C

但是从我所看到的,我访问向量的方式没有任何问题


谢谢。

怎么样
MoveTo()
?另外,您有多个线程吗?顺便问一下,
返回lowerList.empty()
。它在哪一行中断?你使用过调试器吗?在
lowerList.clear()
之前,没有点检查
lowerList.empty()
…也许其他东西正在内存中破坏它,然后-tiem设置write to memeory断点来检查。。。
if(lowerList.empty()){
    return true;
}else
    return false;