3. capacity() returns the number of characters a string could contain without having to reallocate
its internal memory.
Having sufficient capacity is important for two reasons:
1. Reallocation invalidates all references, pointers, and iterators that refer to characters of the string.
2. Reallocation takes time.
Thus, the capacity must be taken into account if a program uses pointers, references, or iterators that
refer to a string or to characters of a string, or if speed is a goal.
The member function reserve() is provided to avoid reallocations. reserve() lets you reserve
a certain capacity before you really need it to ensure that references are valid as long as the capacity
is not exceeded: