📜  如何为向量 C++ 代码示例分配内存

📅  最后修改于: 2022-03-11 14:44:50.841000             🧑  作者: Mango

代码示例1
std::vector vec1;
vec1.reserve(30);  // Allocate space for 30 items, but vec1 is still empty.

std::vector vec2;
vec2.resize(30);  // Allocate space for 30 items, and vec2 now contains 30 items.