C++ vector中實際刪除元素使用的是容器vecrot中std::vector::erase()方法。
C++ 中std::remove()并不刪除元素,因為容器的size()沒有變化,只是元素的替換。
1.std::vector::erase()
函數(shù)原型:iterator erase (iterator position);//刪除指定元素
iterator erase (iterator first, iterator last);//刪除指定范圍內(nèi)的元素
返回值:指向刪除元素(或范圍)的下一個元素。(An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.)
2.代碼實例
-
C++
+關注
關注
22文章
2119瀏覽量
75327 -
Vector
+關注
關注
3文章
76瀏覽量
9262
發(fā)布評論請先 登錄
c++之vector容器

vector用法總結(轉載)
Visual C++ 6.0 高級編程 -下載

C++中vector的定義與初始化

評論