Mega Code Archive
Categories
/
C++
/
Data Structure
Cycle through a map using an iterator
#include
#include
using namespace std; int main() { map
mapObject; int i; for(i = 0; i < 26; i++) mapObject.insert(pair
('A' + i, 65 + i)); map
::iterator p; for(p = mapObject.begin(); p != mapObject.end(); p++) { cout << p->first << " has ASCII value of "; cout << p->second << endl; } return 0; }