
Understanding the Difference Between reserve() and resize()
The capacity of a vector can be resized by calling either reserve() or resize(). These member functions differ in two respects. Unlike resize(), which allocates memory and initializes it with