-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmypoint2f.cpp
66 lines (52 loc) · 1.32 KB
/
mypoint2f.cpp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
// mypoint2f.cpp
// hw3class
//
// Created by ललित सिंह on 28/10/2016.
// Copyright © 2016 ललित सिंह. All rights reserved.
//
//#include "header.hpp"
#include "mypoint2f.hpp"
mypoint2f::mypoint2f(){
this->x = 0;
this->y = 0 ;
}
mypoint2f::mypoint2f(double x, double y ){
this->x = x;
this->y = y;
}
double mypoint2f::getx(){
return this->x;
}
double mypoint2f::gety(){
return this->y;
}
mypoint2f operator-(mypoint2f& a, mypoint2f& b){
mypoint2f result = mypoint2f(a.x - b.x, a.y -b.y);
return result ;
}
mypoint2f operator *(mypoint2f& a, mypoint2f& b){
mypoint2f result = mypoint2f(a.x * b.x, a.y *b.y);
return result ;
}
mypoint2f operator *(double& k, mypoint2f& a){
mypoint2f result = mypoint2f(a.x * k, a.y * k);
return result;
}
mypoint2f operator *(mypoint2f& a, double& k){
mypoint2f result = mypoint2f(a.x * k, a.y * k);
return result;
}
mypoint2f operator + (mypoint2f& a, mypoint2f& b){
mypoint2f result = mypoint2f(a.x + b.x, a.y + b.y);
return result;
}
std::ostream& operator <<(std::ostream& out, mypoint2f& a){
out<<"x:"<<a.getx()<<" y:"<<a.gety()<<std::endl;
return out;
}
bool operator == (mypoint2f& a, mypoint2f& b){
if ( a.x == b.x and a.y == b.y)
return true;
else return false;
}