返回解决成功最后一个元素的位置列表中的常量迭代器。
const_iterator cend( ) const;
返回值
解决成功最后一个元素的位置。list Class的常量双向迭代器。如果 list 为空,然后 list::cend == list::begin。
备注
cend 用于测试迭代器是否已到达其 list的末尾。
示例
// list_cend.cpp
// compile with: /EHsc
#include <list>
#include <iostream>
int main( )
{
using namespace std;
list <int> c1;
list <int>::const_iterator c1_cIter;
c1.push_back( 10 );
c1.push_back( 20 );
c1.push_back( 30 );
c1_cIter = c1.cend( );
c1_cIter--;
cout << "The last integer of c1 is " << *c1_cIter << endl;
}
要求
标头: <list>
命名空间: std