Does someone know the way to define constant-sized vector?
For example, instead of defining
std::vector
it will be
The std::vector can always grow dynamically, but there are two ways you can allocate an initial size:
This allocates initial size and fills the elements with zeroes:
std::vector v(10);
v.size(); //returns 10
This allocates an initial size but does not populate the array with zeroes:
std::vector v;
v.reserve(10);
v.size(); //returns 0