I initialized a vector in my c++ program, then reserved some memory to store values in it. Why I can't assign value to the memory block I had reserved earlier?
vector<int> test;
test.reserve(100);
test[36] = -234;
This doesn't work too:
vector<int> test;
test.reserve(100);
test = {1};
test[1] = -234;
In both cases it raises the same exception:
vector subscript out of range
.
Please help me, thanks very much!