//Overloading Logical Operator "<"
#include<iostream.h>
class Point
{
private:
double M_dX, M_dY;
public:
Point(double dX=0.0, double dY=0.0)
{
M_dX=dX;
M_dY=dY;
}
friend bool operator<(Point &P1, Point &P2);
};
bool operator<(Point &P1, Point &P2)
{
return(P1.M_dX<P2.M_dX && P1.M_dY<P2.M_dY);
}
int main()
{
Point P1(4.55,6.0), P2(4.55,6.0); //Change the value of argument however you like
if(P1<P2)
cout<<"P1<P2=True";
else
cout<<"P1<P2=False";
return(0);
}
#include<iostream.h>
class Point
{
private:
double M_dX, M_dY;
public:
Point(double dX=0.0, double dY=0.0)
{
M_dX=dX;
M_dY=dY;
}
friend bool operator<(Point &P1, Point &P2);
};
bool operator<(Point &P1, Point &P2)
{
return(P1.M_dX<P2.M_dX && P1.M_dY<P2.M_dY);
}
int main()
{
Point P1(4.55,6.0), P2(4.55,6.0); //Change the value of argument however you like
if(P1<P2)
cout<<"P1<P2=True";
else
cout<<"P1<P2=False";
return(0);
}
No comments:
Post a Comment