unordered_map的second使用
时间: 2023-10-12 16:06:39 浏览: 87
在unordered_map中,second是一个成员变量,它存储着unordered_map中每个元素的值。具体来说,当我们使用键来访问unordered_map中的值时,我们可以通过使用键值对的.first成员来获取键,通过使用.second成员来获取对应的值。例如,对于一个unordered_map<int, string>,我们可以使用以下方式访问second的值:
```cpp
unordered_map<int, string> myMap;
myMap = "one";
myMap = "two";
cout << myMap<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [map和unordered_map的使用和差别?unordered_map查询效率这么高,为啥还需要map?](https://blog.csdn.net/JMW1407/article/details/108169804)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [【C++】unordered_set 和 unordered_map 使用 | 封装](https://blog.csdn.net/qq_62939852/article/details/130896774)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [LeetCode判断字符串是否循环-myLeetcode:leetcode刷题日志](https://download.csdn.net/download/weixin_38550834/19950070)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文