Anyone wanna explain this it to me? I looked in the MSDN but that is some cryptic stuff I only have like 1 book (learned everything from examples and help files) but I am not understanding this one too much.
Thanks
Shawn
A map is a so called associative container, which means that it associates objects of type X (the key) with objects of type Y (the data). std::map stores pair objects that consist of a key and the data. In a map, no two objects can have the same key.
You can retrieve the data by specifying a key.
Example:
A map is sorted, and you can supply a function object that specifies the ordering.
Another example would be storing names (the key) and phone numbers (the data).
For more info, see http://www.sgi.com/Technology/STL/Map.html
http://www.sgi.com/Technology/STL/ contains good info on the STL, much better info than MSDN''s documentation on the subject.
Erik
You can retrieve the data by specifying a key.
Example:
map<const char*, int> months;months["january"] = 31;months["february"] = 28;months["march"] = 31;months["april"] = 30;// etc..cout << "june --> " << months["june"] << endl; // will display 30
A map is sorted, and you can supply a function object that specifies the ordering.
Another example would be storing names (the key) and phone numbers (the data).
For more info, see http://www.sgi.com/Technology/STL/Map.html
http://www.sgi.com/Technology/STL/ contains good info on the STL, much better info than MSDN''s documentation on the subject.
Erik
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement