1== friend double dist(point p1, point p2 );
#include <iostream>
#include<cmath>
using namespace std;
class point
{
int x,y;
public:
friend double dist(point p1, point p2 );
point(int xx,int yy) { x=xx; y=yy; }
};
double dist(point p1 ,point p2 )
{
double xxx=p1.x-p2.x , yyy=p1.y-p2.y ;
return sqrt(xxx*xxx + yyy*yyy) ;
}
int main()
{
point p1(0,0),p2(3,4);
cout<<dist(p1,p2)<<endl;
}
#include <iostream>
#include<cmath>
using namespace std;
class point
{
int x,y;
friend double dist(point p1, point p2 );
public:
point(int xx,int yy) { x=xx; y=yy; }
};
double dist(point p1 ,point p2 )
{
double xx=p1.x-p2.x , yy=p1.y-p2.y ;
return sqrt(xx*xx + yy*yy) ;
}
int main()
{
point p1(0,0),p2(3,4);
cout<<dist(p1,p2)<<endl;
}