课程: C++ Standard Template Library

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

Solution: Sets and maps application

Solution: Sets and maps application - C++教程

课程: C++ Standard Template Library

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…

内容