Javatpoint Logo
Javatpoint Logo

C++ std operator>

Operator> is a non-member overloaded function of set in C++. This function is used to check whether the first set is greater than other or not.

Note: Operator> sequentially compares the element of set and comparison will stop at first mismatch.

Syntax

Parameter

lhs: First set object.

rhs: Second set object.

Return value

It returns true if the left side of the set container object is greater than the right side of the set object otherwise, false.

Complexity

Complexity will be constant, if the size of lhs and rhs is different.

Otherwise, up to linear in the size of lhs and rhs.

Iterator validity

No changes.

Data Races

Containers, lhs and rhs are accessed.

Concurrently accessing the elements of unmodified set is always safe.

Exception Safety

This function does not throw an exception.

Example 1

Let's see the simple example to check whether the first set is greater than or not:

Output:

Set m1 is greater than m2.
Set m1 is not greater than m2.

In the above example, there are two sets m1 and m2. m1 contains one element and m2 is empty. When we compare both sets then it will display the message "set m1 is greater than m2" and after assigning m2 to m1 both sets have equal element then it will display the message that "set m1 is not greater than m2".

Example 2

Let's see a simple example:

Output:

The set m1 is not greater than the set m2.
The set m1 is greater than the set m3.

Example 3

Let's see a simple example:

Output:

0
1

In the above example if s1 is greater than s2 then it will return 1 otherwise 0.

Example 4

Output:

1).
---------Login----------

Enter password: 
xyz@123
Password you have entered: 
xyz@123
Password stored in the system :
xyz@123

Welcome to your Page...


2).
---------Login---------

Enter password: 
abc@123
Password you have entered: 
abc@123
Password stored in the system:
xyz@123

Incorrect Password...

In the above example, there are two sets m1 and m2. m1 contains stored password and second set m2 stores user's entered password. It checks whether the m2 is greater than m1 or not. If password of m2 is not greater than m1 then login is successful otherwise, login fails.


Next TopicSet operator>=





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA