const_iterator for map : map iterator « map multimap « C++ Tutorial






#include <map>
#include <iostream>

using namespace std;

typedef map <int, string> MAP_INT_STRING;
typedef multimap <int, string> MMAP_INT_STRING;

int main ()
{
    MAP_INT_STRING mapIntToString;

    mapIntToString.insert (MAP_INT_STRING::value_type (3, "Three"));

    MAP_INT_STRING::const_iterator iMapPairLocator;

    for ( iMapPairLocator = mapIntToString.begin (); iMapPairLocator != mapIntToString.end (); ++ iMapPairLocator )
    {
        cout << "Key: " << iMapPairLocator->first;
        cout << " Value: " << iMapPairLocator->second.c_str ();

        cout << endl;
    }

    return 0;
}








23.7.map iterator
23.7.1.Use iterator to loop through map and print all elements
23.7.2.Loop through map and print all the key/value pair
23.7.3.Display the first element in map
23.7.4.Display the last element in map
23.7.5.reverse_iterator from map
23.7.6.Cycle through the map in the reverse direction
23.7.7.Declare a reverse iterator to a map
23.7.8.Declare an iterator to a map
23.7.9.const_iterator for map
23.7.10.Create int string map and print all element pair