Answers for "how to allocate memory for vector c++"

C++
0

how to allocate memory for vector c++

std::vector<int> vec1;
vec1.reserve(30);  // Allocate space for 30 items, but vec1 is still empty.

std::vector<int> vec2;
vec2.resize(30);  // Allocate space for 30 items, and vec2 now contains 30 items.
Posted by: Guest on August-09-2021

Browse Popular Code Answers by Language