vector c++ reserve vs resize code example
Example: c++ vector resize
std::vector<int> vec = {1, 2, 3};
vec.resize(2); // {1, 2}
vec.resize(4); // {1, 2, 0, 0,}
vec.resize(6, 9); // {1, 2, 0, 0, 9, 9}
std::vector<int> vec = {1, 2, 3};
vec.resize(2); // {1, 2}
vec.resize(4); // {1, 2, 0, 0,}
vec.resize(6, 9); // {1, 2, 0, 0, 9, 9}