Map for string key and integer value
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string, int, less<string> > name_age;
name_age["A"] = 7;
name_age["B"] = 39;
name_age["C"] = 14;
cout << "A is "
<< name_age["A"]
<< " years old." << endl;
}
Related examples in the same category