Size versus Capacity
We'll test and alter the capacity of a string.
The number of elements a string has (str.size()
) is in general smaller than the number of elements for which space is reserved: str.capacity()
. Therefore if we add elements to a string, new memory will not necessarily be allocated. std:max_size()
return the maximum amount of elements a string can have. ...