C++ Multiset operator!=C++ Multiset operator!= is a non-member overloaded function of multiset in C++ language. This function is used to check whether the two multisets are equal or not. Note: Comparison between multiset objects is based on a pair wise comparison of the elements. Two multisets 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 multiset object. rhs: Second multiset object. Return valueIt returns true if the left side of the multiset object is equal to the right side of the multiset object otherwise, false. ComplexityComplexity will be constant, if the size of lhs and rhs is different. Otherwise, up to linear in the size of lhs and rhs. Iterator validityNo changes. Data RacesContainers, lhs and rhs are accessed. Concurrently accessing the elements of unmodified multiset is always safe. Exception SafetyThis function does not throw an exception. Example 1Let's see the simple example to check whether the two multisets are equal or not: Output: Both multisets are not equal. Both multisets are equal. In the above example, there are two multisets m1 and m2. m1 contains one element and m2 is empty. When we compare both multisets then it will display the message "both multisets are not equal" and after assigning m1 to m2 both multisets have equal element then it will display the message that "both multisets are equal". Example 2Let's see a simple example: Output: The multisets m1 and m2 are not equal. The multisets m1 and m3 are equal. Example 3Let's see a simple example: Output: 0 1 In the above example, if multiset s1 and s2 are equal then it will return 1 otherwise 0. Example 4Output: 1). ---------Login---------- Enter password: xyz Password you have entered: xyz Password stored in the system: xyz@123 Incorrect Password... 2). ---------Login---------- Enter password: xyz@123 Password you have entered: xyz@123 Password stored in the system: xyz@123 Welcome to your Page... In the above example, there are two multisets m1 and m2. m1 contains stored password and second multiset m2 stores user?s entered password. It checks whether the both multiset has same elements or not. If password will match then login is successful otherwise, login fails. Next TopicC++ multiset |
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