Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns a const iterator addressing the first element in the map.
const_iterator cbegin( ) const;
Return Value
A const bidirectional iterator addressing the first element in the map Class or the ___location succeeding an empty map.
Remark
With the return value of cbegin, the elements in the map object cannot be modified.
Example
// map_cbegin.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 ( 0, 0 ) );
m1.insert ( Int_Pair ( 1, 1 ) );
m1.insert ( Int_Pair ( 2, 4 ) );
m1_cIter = m1.cbegin ( );
cout << "The first element of m1 is " << m1_cIter -> first << endl;
}
The first element of m1 is 0
Requirements
Header: <map>
Namespace: std