ok this is how it goes
you can give the vector an initial size in its ctor, eg
<pre>vector<int> v(10);</pre>
or, you can create space using <pre>v.resize()</pre> (which was undocumented in my paper reference, which that plus my old compiler is my lame excuse
) or v.assign(). v.reserve() will reserve space but not allocate nor initialize it. you use it to say "my vector will probably reach around this size but not right now", vs v.resize() which says "please give me this much space now kthx". with v.reserve you still have to call v.resize() before you actually use the space.
the reason behind v.reserve() has to do with pointers. say you have a 10 element vector of items, and for whatever reason you have a pointer that points to one of the elements. if you later call v.resize(), the language may have to allocate more space in another region of memory and move everything there. if this happens the pointer you have will no longer point to the correct place. to counter this they created v.reserve(). with your 10 element vector if you called v.reserve(100), you could at any time call v.resize() with an argument upto 100 and its guarenteed by the language not to move things about in memory, so your pointer will still point to the right place.
if the above paragraph confuses you, dont worry, its not too important to understand.
hth