Program To Overload Relational "<" Operator
#include<iostream>using namespace std;
class sample
{
int x;
public:
sample()
{
cout<<"\n Enter Any Value";
cin>>x;
}
int operator <(sample &s)
{
if(x<s.x)
{
return 1;
}
else
{
return 0;
}
}
void display()
{
cout<<x;
}
};
main()
{
sample c,d;
if(c<d)
{
cout<<"\n Smaller is ";
c.display();
}
else
{
cout<<"\nSmaller is ";
d.display();
}
}