ฟังก์ชัน C++ std::unordered_multimap::operator=() กำหนดเนื้อหาใหม่ให้กับ theunordered_multimap โดยแทนที่อันเก่าและแก้ไขขนาดหากจำเป็น
ต่อไปนี้เป็นการประกาศสำหรับ std::unordered_multimap::operator=() ฟังก์ชัน formtd::unordered_map() ส่วนหัว
C++11 (ไวยากรณ์)
unordered_multimap& operator=(const unordered_multimap& umm);
พารามิเตอร์
umm - Another unordered_multimap object of same type.
ผลตอบแทนที่ได้รับ
Returns this pointer.
โค้ดตัวอย่าง
#include <iostream>
#include <unordered_map>
using namespace std;
int main(void) {
unordered_multimap umm1 = {
{'a', 1},
{'b', 2},
{'c', 3},
{'d', 4},
{'e', 5},
};
unordered_multimap umm2;
umm2 = umm1;
cout << "Unordered multimap contains following elements" << endl;
for (auto it = umm2.begin(); it != umm2.end(); ++it)
cout << it->first << " = " << it->second << endl;
return 0;
} ผลลัพธ์
Unordered multimap contains following elements e = 5 a = 1 b = 2 c = 3 d = 4