wince vector problem, i need help
-
std::vector<int> test1; test1.resize(15); int sz = test1.size(); for (int i = 0; i < sz; i++) { test1[i] = i; } for (int i = 0; i < sz; i++) { int val = test1[i]; } std::vector<int> test2; test2.resize(20); sz = test2.size(); for (int i = 0; i < sz; i++) { test1[i] = i; } for (int i = 0; i < sz; i++) { int val = test1[i]; }
error: index out of range
IDE: vs2008
QT: qt4.7.3 for everywhere
i do it like this article :
https://forum.qt.io/topic/19049/qt-under-windows-ce-is-very-slow  
-
@CraigTao said in wince vector problem, i need help:
std::vector<int> test2;
test2.resize(20);
sz = test2.size();
for (int i = 0; i < sz; i++)
{
test1[i] = i;
}for (int i = 0; i < sz; i++)
{
int val = test1[i];
}sz = test2.size() ==> and in loop you are using test1.
test1
has only 15 elements!change your loop to:
for (int i = 0; i < test1.size(); i++) { test1[i] = i; }
-
i do it don't like this article :
https://forum.qt.io/topic/19049/qt-under-windows-ce-is-very-slowstill error, vector index out of range
i used qt4.8 wince, still this error,