Erase(数组的清除和重新定义)

Erase:vt.擦掉; 抹去; 擦掉; 清除; Erase 语句 (Visual Basic)。数组的清除和重新定义,程序是定义了一个静态数组 T,用 For循环语句为每个数组的元素赋值,然后执行 Erase语句,将各数组元素的值清除。

简述

描述

重新初始化固定大小数组的元素,并释放动态数组的存储空间。

语法

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.

该文章由作者:【土狼】发布,本站仅提供存储、如有版权、错误、违法等相关信息请联系,本站会在1个工作日内进行整改,谢谢!

发表回复

登录后才能评论