From the course: C++ Standard Template Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Sets and maps application

Solution: Sets and maps application - C++ Tutorial

From the course: C++ Standard Template Library

Start my 1-month free trial

Solution: Sets and maps application

- [Instructor] So here is my solution. We will start with a file that is very similar to the last map example code we just wrote. So notice how the main function, starting at line 11, first defines a map update called hotel which has a key that is an integer and the content is a string. And then starting at line 17, we have the same round of insertions we have been using. So we will reuse that code. And finally, starting at line 31, we have the lines of code that print out the content of the map. So I hope you can see that this application of the map container we just wrote, works very well for this challenge. So we will start writing the remaining part of the testing code. I will start that in line 36. Now we will try to enter a new entry with an existing key. We will get that integer value the usual way, and we will assign that to the first element of the temporary pair. Then we ask for a name, and assign it to the second element of the pair, and we are ready to insert this entry…

Contents