-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
39 lines (31 loc) · 707 Bytes
/
Point.cpp
File metadata and controls
39 lines (31 loc) · 707 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
#include "Point.h"
#include <iostream>
Point::Point(){
x = 0;
y = 0;
z = 0;
}
Point::Point(double x, double y, double z){
this->x = x;
this->y = y;
this->z = z;
}
const Point& Point::operator=(const Point& other){
x = other.x;
y = other.y;
z = other.z;
return *this;
}
ostream& operator<<(ostream& out, const Point& point){
out << point.x << " " << point.y << " " << point.z << endl;
return out;
}
Point operator-(const Point& a, const Point& b){
return Point(a.x - b.x, a.y - b.y, a.z - b.z);
}
Point operator+(const Point& a, const Point& b){
return Point(a.x + b.x, a.y + b.y, a.z + b.z);
}
Point operator*(const Point& a, const int b){
return Point(a.x * b, a.y * b, a.z * b);
}