Learn about the STL map, which provides sorted key-value pairs, like an associative array. This is useful for key-value relationships.
- [Narrator] The map class provides a sorted set…of key-value pairs, like an associative arary.…Here I have a working copy of map.cpp…from chapter two of the exercise files.…And you see we have our normal stuff up the top here.…We can print the elements of a map.…That calls print_pair, because each of the elements…in a map is a pair, and so print_pair…prints the first and second elements of the pair.…We have some print a message things here,…and then we get on to main.…And you'll notice here on line 31,…I initialize a map object, and this is a map of strings,…and so you notice I have string for the two different values…for the key and the value pair,…and so I'm initializing it with an initializer list,…and each of these elements in the initializer list…is a pair, and so I guess I have initializer lists…within the initializer list, and that works just great.…
And you'll notice there's four elements here,…George, Ellen, Ruth, and Spike,…and so when I build and run this,…I'll scroll up here to the top,…and you see that the size of the object is four…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.