C++ multimap operator==C++ operator== is a non-member overloaded function of multimap. This function is used to check whether the two multimaps are equal or not. Note: Comparison between multimaps objects depend on a pair wise comparison of the elements. Two mappings are equal if they have the same number of elements and their corresponding elements have the same values. Otherwise they are not equal.SyntaxParameterlhs: First multimap object. rhs: Second multimap object. Return valueIt returns true if the left side of the multimap object is equal to the right side of the multimap object otherwise false. ComplexityComplexity will be constant, if the size of lhs and rhs is different. Otherwise, up to linear in the size (equality comparisons). Iterator validityNo changes. Data RacesContainers, lhs and rhs are accessed. Exception SafetyThis function does not throw an exception. Example 1Let's see the simple example to check whether the two multimaps are equal or not: Output: Both multimaps are equal. Both multimaps are not equal. In the above example, multimap m1 and m2 are empty. Therefore operator== will return true and after adding one element in multimap m1 size of m1 becomes different to size of m2. Therefore, it will return false. Example 2Let's see a simple example: Output: The multimaps m1 and m2 are not equal. The multimaps m1 and m3 are equal. Example 3Let's see a simple example: Output: 1 0 In the above example if m1 and m2 are equal then it will return 1 otherwise 0. Example 4Output: 1). ---------Login---------- Enter the ID and password: 1020 xyz ID and password you have entered: 1020 xyz ID and Password stored in the system: 2040 xyz@123 Incorrect ID or Password... 2). ---------Login---------- Enter the ID and password: 2040 xyz@123 ID and password you have entered: 2040 xyz@123 ID and Password stored in the system: 2040 xyz@123 Welcome to your Page... In the above example, there are two multimaps m1 and m2. m1 contains stored ID and password and second multimap m2 stores user's entered ID and password. It checks whether the both multimap has same elements or not. If ID and password will match then login is successful otherwise login fails. Next TopicC++ Multimap |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India