Erase

Erase

數組的清除和重新定義
Erase:vt.擦掉; 抹去; 擦掉; 清除; Erase 語句 (Visual Basic)。[1]數組的清除和重新定義,程序是定義了一個靜态數組 T,用 For循環語句為每個數組的元素賦值,然後執行 Erase語句,将各數組元素的值清除。
  • 中文名:Erase
  • 外文名:
  • 别名:
  • 語法:Erasearray
  • 釋放:動态數組的存儲空間

簡述

描述

重新初始化固定大小數組的元素,并釋放動态數組的存儲空間。

語法

array 參數是要清除的數組變量的名稱;

iterator erase( iterator pos );

iterator erase( iterator start, iterator end );

basic_string &erase( size_type index = 0, size_type num = npos );

删除pos指向的字符, 返回指向下一個字符的叠代器;

删除從start到end的所有字符, 返回一個叠代器,指向被删除的最後一個字符的下一個位置;

删除從index索引開始的num個字符, 返回*this;

參數index 和 num 有默認值, 這意味着erase()可以這樣調用:隻帶有index以删除index後的所有字符,或者不帶有任何參數以删除所有字符。

參數

First

An iterator addressing the position of the first element in the range to be erased.

Last

An iterator addressing the position one past the last element in the range to be erased.

It

An iterator addressing the position of the element in the string to be erased.

Pos

The index of the first character in the string to be removed.

Count

The number of elements that will be removed if there are as many in the range of the string beginning with _Pos.

返回值

For the first two member functions, an iterator addressing the first character after the last character removed by the member function. For the third member function, a reference to the string object from which the elements have been erased.

相關詞條

相關搜索

其它詞條