.
std::vector<T> vectorOfTs(n);
In the above statement, in fact, you create "n" the number of new instances of type T (that is, by default, the default constructor T () will run.) Now the vector vectorOfTs contains n elements. For the above statement, the next version of the vector constructor is called.
explicit vector ( size_type n, const T& value= T(), const Allocator& = Allocator() );
So, when you drop another element into a vector, the size of the vector will be n + 1.
source
share