vector :: resize () will resize it and fill it with default objects (int, in this case, it does not matter).
vector :: reserve () will allocate space without filling it.
You can add additional elements using, for example, push_back (), until you have as many items that you need - if necessary, it will resize.
source
share