Compartir a través de


map::cbegin

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

See Also

Reference

map Class

Standard Template Library

Other Resources

map Members