Associating Objects with map - C++ STL

C++ examples for STL:map

Description

Associating Objects with map

Demo Code

#include <iostream> 
#include <map> 
#include <string> 
using namespace std; 

int main() //  ww  w  . j a  v a 2s  .com
{ 
    map<string, string> marriages; 

    marriages["Tom"] = "T"; 
    marriages["Harry"] = "H"; 

    cout << marriages["Tom"] << endl; 
    cout << marriages["Harry"] << endl; 

    return 0; 
}

Result


Related Tutorials