有问题的向量声明如下:
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。
但据我所知,我访问向量的方式没有任何问题。
谢谢。