Roger
2006-11-06 15:02:10 UTC
I thought the difference between vector reserve and resize was:
reserve - just allocates space but doesn't create any elements in the vector
i.e. push_backs are required
resize - creates the elements so push_backs are not required
If that is true how come the following works in both cases:
ElapsedTimer(START);
for (int i = 0; i < 1000000 ;++i)
{
stTest.nTest = i;
stTest.dTest = i * 3.14;
vTest[i] = stTest;
} // End of For ()
ElapsedTimer(END);
cout << vTest[200].dTest << endl;
vTest.clear();
cout << vTest[200].dTest << endl; // Also why isn't this number cleared
Are these bugs in BCB6?
Roger
reserve - just allocates space but doesn't create any elements in the vector
i.e. push_backs are required
resize - creates the elements so push_backs are not required
If that is true how come the following works in both cases:
ElapsedTimer(START);
for (int i = 0; i < 1000000 ;++i)
{
stTest.nTest = i;
stTest.dTest = i * 3.14;
vTest[i] = stTest;
} // End of For ()
ElapsedTimer(END);
cout << vTest[200].dTest << endl;
vTest.clear();
cout << vTest[200].dTest << endl; // Also why isn't this number cleared
Are these bugs in BCB6?
Roger