向量抛出“访问冲突读取位置”异常。 C ++。 VS 2012

时间:2013-02-28 21:31:02

标签: c++ exception vector visual-studio-2012

有问题的向量声明如下:

vector<int> lowerList;

如果向量在非空时使用:

清除
if(!lowerList.empty()){
    lowerList.clear();
}

然后使用:

将向量填充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。

但是我可以看到我访问我的矢量的方式没有任何问题。

感谢。

0 个答案:

没有答案