With the constructor:
// create a vector with 20 integer elements
std::vector<int> arr(20);
for(int x = 0; x < 20; ++x)
arr[x] = x;
More Related Contents:
- Invalid operands to binary expression while implementing vector [closed]
- Difficulties on atributting a array to another [closed]
- Erasing elements from a vector
- Why can’t I make a vector of references?
- Choice between vector::resize() and vector::reserve()
- Does C++11 allow vector?
- When vectors are allocated, do they use memory on the heap or the stack?
- How can I create cartesian product of vector of vectors?
- Is this behavior of vector::resize(size_type n) under C++11 and Boost.Container correct?
- vector size – 1 when size is 0 in C++
- Erasing from a std::vector while doing a for each?
- How to cin values into a vector
- How to use std::sort with a vector of structures and compare function?
- What is the simplest way to convert array to vector?
- pop_back() return value?
- How to implement 2D vector array?
- std::vector, default construction, C++11 and breaking changes
- How to navigate through a vector using iterators? (C++)
- Compute Median of Values Stored In Vector – C++?
- How to make elements of vector unique? (remove non adjacent duplicates)
- Does resizing a vector invalidate iterators?
- size vs capacity of a vector?
- Why doesn’t emplace_back() use uniform initialization?
- Erase element in vector while iterating the same vector [duplicate]
- How to use new std::byte type in places where old-style unsigned char is needed?
- How to erase & delete pointers to objects stored in a vector?
- C++ STL: Array vs Vector: Raw element accessing performance
- Write concurrently vector
- C++ trying to swap values in a vector
- C++ – value of uninitialized vector