Mega Code Archive
Categories
/
C++
/
Data Structure
Maps can store only unique keys
#include
#include
using namespace std; int main() { map
mapObject; pair
::iterator, bool> res; res = mapObject.insert(pair
('A', 65)); if(res.second) cout << "Insertion occured.\n"; res = mapObject.insert(pair
('A', 99)); if(!res.second) cout << "Duplicate not allowed.\n"; map
::iterator p; p = mapObject.find('A'); cout << "Its ASCII value is " << p->second; return 0; }