This is the number of actual objects held in the vector, which is not necessarily equal to its storage capacity. Vectors automatically reallocate their storage space when needed or when requested with member resize. To retrieve the current storage capacity of a vector you can call to its member capacity.
Parameters
noneReturn Value
The number of elements that conform the vector's content.Member type size_type is an unsigned integral type.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Output:
0. size: 0 1. size: 10 2. size: 20 3. size: 19 |
Complexity
Constant.See also
| vector::capacity | Return size of allocated storage capacity (public member function) |
| vector::resize | Change size (public member function) |
| vector::max_size | Return maximum size (public member function) |
