So from what I understand, reserve doesn’t initialize the the abstractions but simply allocates space in order to contain them. However shouldn’t v[0] always give you the first unitialized memory and shouldn’t assigning a value into it always work?
So from what I understand, reserve doesn’t initialize the the abstractions but simply allocates
Share
Because
reservedoes not change the size of the vector. It only moves the vector to a place in memory where there is enough space to allow the size of the vector to increase when it becomes necessary.If you want to be sure you can call
v[0]=2, or evenv[1]=0, you should useresize(2), notreserve(2).