Answers for "c++ vector::reserve vs resize"

C++
2

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}
Posted by: Guest on January-22-2021

Browse Popular Code Answers by Language