thanks for your reply. I don't understand how your #define USE_PUSH works. Another thing, my question is precisely because reserve() method does not allow direct access since reserve() is a bunch of addresses and not numbers. You need to fill the array first in order to directly access into it. But I don't understand why in the code 1 above it is working. If I do the following:

vector<double> vec;

for (i = 0 ; i < 5; i++)
   vec[i] = 10;
will not work.