我寫C++代碼的圖形程序,並在其中我要收集所有的座標以後解析them.I'm試圖使用相同的載體,但下面的錯誤返回:向量下標越界,調試斷言失敗
調試斷言失敗
計劃:....
文件:....
線932
表達:向量下標越界
這裏是我的代碼部分:
std::vector<float> coordinates;
//random code
if(dnew >= 0)
{
x = x + 1.0;
glPointSize(1.5f);
glColor3f(0.0,1.0,1.0);
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
dnew = dnew + a;
if(t == 1)
{
coordinates.push_back (x);
}
}
cout <<coordinates[1];
當我按下重試帶我到stdthrow.cpp並指向以下行:
_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL _Debug_message(const wchar_t *message, const wchar_t *file, unsigned int line)
{
// report error and die
if(::_CrtDbgReportW(_CRT_ASSERT, file, line, NULL, message)==1)
{
::_CrtDbgBreak();
}
}
什麼是你的問題?這個錯誤非常明顯。 (你最有可能隱藏包含錯誤的代碼的''.....在'for'聲明。) –
的(......)?我們需要真正的迴路來回答你的問題。 – ForEveR
我們不需要看到'爲(.....)'...拿去....我們只猜... –