map::cend
傳回 const 將結束 Iterator。
const_iterator cend( ) const;
傳回值
透過這個結束 Iterator。如果 map Class 是 null,則 map::cend() == map::begin()。
備註
cend 用來測試 Iterator 是否超過其 map的結尾。
不應該取值 cend 傳回的值。
範例
// map_cend.cpp
// compile with: /EHsc
#include <map>
#include <iostream>
int main( )
{
using namespace std;
map <int, int> m1;
map <int, int> :: const_iterator m1_cIter;
typedef pair <int, int> Int_Pair;
m1.insert ( Int_Pair ( 1, 10 ) );
m1.insert ( Int_Pair ( 2, 20 ) );
m1.insert ( Int_Pair ( 3, 30 ) );
m1_cIter = m1.cend( );
m1_cIter--;
cout << "The value of the last element of m1 is:\n"
<< m1_cIter -> second << endl;
}
需求
標題: <map>
命名空間: std