- create an empty vector,
push_back()
elements into it. - create an empty vector, allocate some capacity with
reserve()
, thenpush_back()
elements into it. - create a vector of
n
elements, use indexing and copy-assignment. - create an empty vector,
emplace_back()
elements into it. - create an empty vector, allocate some capacity with
reserve()
, thenemplace_back()
elements into it.
There are other ways, e.g. creating the container with a pair of iterators, or filling it via standard library algorithms. I won't consider these here.