删除函数:删除函数(erase)



删除(erase)
语法: iterator erase( iterator pos );
iterator erase( iterator start, iterator end );
basic_ &erase( size_type index = 0, size_type num = npos );


erase可以:

删除pos指向, 返回指向下迭代器,
删除从start到end所有, 返回个迭代器,指向被删除最后个位置
删除从index索引开始num个, 返回*this.
参数index 和 num 有默认值, 这意味着erase可以这样:只带有index以删除index后所有或者不带有任何参数以删除所有. 例如:

s("So, you like donuts, eh? Well, have all the donuts in the world!");
cout << "The original is '" << s << "'" << endl;

s.erase( 50, 14 );
cout << "Now the is '" << s << "'" << endl;

s.erase( 24 );
cout << "Now the is '" << s << "'" << endl;

s.erase;
cout << "Now the is '" << s << "'" << endl;
将显示

The original is 'So, you like donuts, eh? Well, have all the donuts in the world!'
Now the is 'So, you like donuts, eh? Well, have all the donuts'
Now the is 'So, you like donuts, eh?'
Now the is ''
Tags:  excel删除函数 php删除文件函数 删除文件函数 删除函数

延伸阅读

最新评论

发表评论