We can create std::vector in this way:
std::vector<int> numbers(n, value);
It is possible not to pass the second parameter to the constructor.
But are we guaranteed that if we create std::vector of ints' it will be filled with zeroes?
We can create std::vector in this way:
std::vector<int> numbers(n, value);
It is possible not to pass the second parameter to the constructor.
But are we guaranteed that if we create std::vector of ints' it will be filled with zeroes?
If the initializer is not explicitly specified, the objects are value initialized using the construction
T(). For fundamental types, as for example the typeint, it means zero-initialization.So, this declaration:
Is, in fact, equivalent to:
Here is a demonstration program:
The program output is