//============================================================================
// Name : friend.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<cmath>
#include<math.h>
using namespace std;
class Point {
private:
double x, y;
public:
Point(double x, double y) {
this->x = x;
this->y = y;
}
double getX() {
return x;
}
double getY() {
return y;
}
friend double Distance(Point &a, Point &b);
};
double Distance(Point &a, Point &b) {
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
int main() {
Point a(3, 4), b(5, 6);
cout << Distance(a, b);
return 0;
}
// Name : friend.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include<cmath>
#include<math.h>
using namespace std;
class Point {
private:
double x, y;
public:
Point(double x, double y) {
this->x = x;
this->y = y;
}
double getX() {
return x;
}
double getY() {
return y;
}
friend double Distance(Point &a, Point &b);
};
double Distance(Point &a, Point &b) {
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
int main() {
Point a(3, 4), b(5, 6);
cout << Distance(a, b);
return 0;
}