-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path28Q.cpp
More file actions
43 lines (34 loc) · 720 Bytes
/
Copy path28Q.cpp
File metadata and controls
43 lines (34 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <math.h>
#include<cmath>
using namespace std;
class point
{
int x, y;
public:
point(int a, int b)
{
x = a;
y = b;
}
friend double distanceCalc(point, point);
void displayPoint()
{
cout << "the point is (" << x << ", " << y << ")" << endl;
}
};
// Create a fucntion which takes two point objects and compute the distance between two points.
double distanceCalc(point p1, point p2)
{
double d = sqrt(pow((p1.x - p2.x), 2) + pow((p1.y - p2.y), 2));
cout<<"the distance is "<<d<<endl;
};
int main()
{
point p(1, 1);
p.displayPoint();
point q(4, 6);
q.displayPoint();
distanceCalc(q, p);
return 0;
}