Let’s check the tutorial of overloading insertion and extraction operator in c++.
C++ Program to overload the Greater than > operator
In this program, we try to overload the < operator with C++. Less number C++ Program with operator overloading.
// < (Less than)Operator overloading
#include<iostream>
using namespace std;
class T4Tutorials
{
private :
int num;
public :
void input()
{
cin>>num;
}
int operator < (T4Tutorials x)
{
if(num<x.num)
return 1;
else
return 0;
}
};
int main()
{
T4Tutorials n1,n2;
cout<<"Please enter 1st number. ";
n1.input();
cout<<" Please enter 1st number .";
n2.input();
if(n1<n2)
{
cout<<"n1 is less than n2. ";
}
else
{
cout<<"n1 is not less than n2. ";
}
return 0;
}
Output
Please enter 1st number. 6
Please enter 2nd number. 5
n1 is not less than n2.
Video Lecture
- Less than operator overloading in c++ example.
- Less than operator overloading.
- < operator overloading in c++ example.
- < operator overloading.
- Relational operator overloading in c++ with programs.
- Overload comparison operator c++.
- Overloading stream insertion (<>) operators in C++.

