2011-03-17 95 views

回答

20
vec.resize(10); // drops the rest (capacity remains the same) 
4
theVector.erase(theVector.begin() + 10, theVector.begin() + 100); 
23

是的,有一個erase函數接受參數的第一個和最後。

v.erase(v.begin() + 10, v.end()); 
+0

感謝名單爲這一個! – 2012-03-29 14:51:27

5

vec.erase(vec.begin() + 10, vec.begin() + 100);