#include<iostream.h>
#include<conio.h>
class point
{
int x;
int y;
public:
void accept()
{
cout<<"\n\nEnter x co-ordinate : ";
cin>>x;
cout<<"\n\nEnter y co-ordinate : ";
cin>>y;
}
  void disp()
  {
cout<<"("<<x<<","<<y<<")\n";
  }
  friend point operator -(point,point);
};
point operator -(point p1,point p2)
{
point p3;
p3.x=p1.x-p2.x;
p3.y=p1.y-p2.y;
return p3;
}
int main()
{
clrscr();
point p1,p2,p3;
cout<<"\n\nEnter first point : ";
p1.accept();
cout<<"\n\nEnter second point : ";
p2.accept();
p3=p1-p2;
cout<<"\n\nFirst point is : ";
p1.disp();
cout<<"\n\nSecond point is : ";
p2.disp();
cout<<"\n\nDistance between two points is : ";
p3.disp();
getch();
return(0);
};

Post a Comment

Previous Post Next Post