I have a std::vector
variable in my C++
application. The size of the vector is determined at runtime, but is typically about 1000<
-
Yes, you can use std::vector::resize
, which just truncates if the length of the vector is greater than n.
See here: http://www.cplusplus.com/reference/vector/vector/resize/
std::vector<int> myvector;
for (int i=1;i<1000;i++) myvector.push_back(i);
myvector.resize(50);
// myvector will contain values 1..50
讨论(0)
- 热议问题