सी ++ में मल्टीमैप वास्तव में अजीब काम करने के लिए लगता है, मैं चाहते हैं पता करने के लिए क्योंunordered_multimap - ढूंढें का परिणाम (पुनरावृत्ति) भिन्न मान के साथ तत्वों पैदावार
#include <iostream>
#include <unordered_map>
using namespace std;
typedef unordered_multimap<char,int> MyMap;
int main(int argc, char **argv)
{
MyMap map;
map.insert(MyMap::value_type('a', 1));
map.insert(MyMap::value_type('b', 2));
map.insert(MyMap::value_type('c', 3));
map.insert(MyMap::value_type('d', 4));
map.insert(MyMap::value_type('a', 7));
map.insert(MyMap::value_type('b', 18));
for(auto it = map.begin(); it != map.end(); it++) {
cout << it->first << '\t';
cout << it->second << endl;
}
cout << "all values to a" << endl;
for(auto it = map.find('a'); it != map.end(); it++) {
cout << it->first << '\t' << it->second << endl;
}
}
इस उत्पादन है:
c 3
d 4
a 1
a 7
b 2
b 18
all values to a
a 1
a 7
b 2
b 18
जब भी मैं स्पष्ट रूप से 'ए' मांग रहा हूं तो आउटपुट में अभी भी कुंजी के साथ कुछ भी क्यों शामिल है? क्या यह एक कंपाइलर या एसएलएल बग है?
अगर आप बदलना -> करने के लिए। तो मैं आपका जवाब स्वीकार करूंगा। – Arne
मुझे '-> 'खुश मिला। – user7116