-1
我嘗試從矢量中刪除元素,並且它在erase()方法下正常工作,但刪除元素後,矢量的大小仍然相同。從向量中刪除元素並更改大小
std::vector<int> myvector;
myvector.push_back (1);
myvector.push_back (2);
myvector.push_back (3);//here the size is 3
myvector.erase(myvector.begin()+1);//I think normally the size should be 2 after removing the element
是有可以做,或者我應該做手工的功能,我是新來的C++我檢查的文件,我沒有找到一個解決方案。
你真的檢查什麼'尺寸()'你擦除電話後的回報? – inf 2014-12-01 20:13:44
我在調用erase()後檢查了大小,它仍然是一樣的 – 2014-12-01 20:15:11
然後你的標準庫被破壞了。 – juanchopanza 2014-12-01 20:17:57