C++ vector中實(shí)際刪除元素使用的是容器vecrot中std::vector::erase()方法。
C++ 中std::remove()并不刪除元素,因?yàn)槿萜鞯膕ize()沒(méi)有變化,只是元素的替換。
1.std::vector::erase()
函數(shù)原型:iterator erase (iterator position);//刪除指定元素
iterator erase (iterator first, iterator last);//刪除指定范圍內(nèi)的元素
返回值:指向刪除元素(或范圍)的下一個(gè)元素。(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.代碼實(shí)例
-
C++
+關(guān)注
關(guān)注
22文章
2116瀏覽量
74568 -
Vector
+關(guān)注
關(guān)注
3文章
65瀏覽量
8964
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
c++之vector容器

vector用法總結(jié)(轉(zhuǎn)載)
Visual C++ 6.0 高級(jí)編程 -下載

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

評(píng)論