Using [] in Map
![Using [] in Map](https://web.archive.org/web/20150427042853im_/http://www.java2s.com/Code/CppImages/UsinginMap.PNG)
#include <iostream>
#include <map>
using namespace std;
int main()
{
map<char, int> mapObject;
int i;
for(i = 0; i < 26; i++)
mapObject.insert(pair<char, int>('A' + i, 65 + i));
char ch;
cout << "Enter key: ";
cin >> ch;
cout << "Its ASCII value is " << mapObject[ ch ];
return 0;
}
Related examples in the same category