 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
multimap::operator= in C++ STL
In this article, we will be discussing the working, syntax, and example of multimap equal ‘=’ operator in C++ STL.
What is Multimap in C++ STL?
Multimaps are the associative containers, which are similar to map containers. It also facilitates storing the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.
What is multimap equal to ‘=’ operator?
multimap::operator= is equal to operator. This operator is used to copy the elements from one container to another container, by overwriting the current content of the container.
Syntax
multiMap_name1 = multimap_name2;
Parameter
There is a multimap on the left side of the operator and another multimap on the right side of the container. The contents of the right side are copied to the multimap on the left side.
Return value
There is no return value of an operator.
Input
multimap<char, int> newmap, themap; newmap.insert({1, 20}); newmap.insert({2, 30}); themap = newmap; Output
themap = 1:20 2:30
Example
#include<iostream> #include<map> using namespace std; int main(){    multimap<int,char > mul_1;    multimap<int,char> mul_2;    //declaring iterator to traverse the elements    multimap<int,char>:: iterator i;    //inserting elements to multimap1    mul_1.insert(make_pair(0,'a'));    mul_1.insert(make_pair(1,'b'));    mul_1.insert(make_pair(2,'c'));    mul_1.insert(make_pair(3,'d'));    //inserting elements to multimap2    mul_2.insert(make_pair(4,'e'));    mul_2.insert(make_pair(5,'f'));    mul_2.insert(make_pair(6,'g'));    //calling = operator    mul_1= mul_2;    //elements of multimap1    cout<<"Elements in multimap1 are: "<<"\n";    for( i = mul_1.begin(); i!= mul_1.end(); i++) {       cout<<(*i).first<<" "<< (*i).second << "\n";    }    //elements of multimap2    cout<<"\nElements in multimap2 are: "<<"\n";    for( i = mul_2.begin(); i!= mul_2.end(); i++) {       cout<<(*i).first<<" "<< (*i).second << "\n";    } } Output
If we run the above code it will generate the following output −
Elements in multimap1 are: 4 e 5 f 6 g Elements in multimap2 are: 4 e 5 f 6 g
