-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVector.h
52 lines (40 loc) · 1.03 KB
/
Vector.h
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
#ifndef VECTOR_H
#define VECTOR_H
namespace de300 {
template <class T> class Vector {
public :
T a;
T b;
Vector<T>(T aa, T ba);
Vector<T> operator+(const Vector<T>& m);
Vector<T> operator-(const Vector<T>& m);
Vector<T> operator*(T m);
Vector<T> operator/(T d);
};
template <class T>
Vector<T>::Vector(T aa, T ba) {
a = aa;
b = ba;
}
template <class T>
Vector<T> Vector<T>::operator+(const Vector<T>& m) {
Vector result(m.a + a, m.b + b);
return result;
}
template <class T>
Vector<T> Vector<T>::operator-(const Vector<T>& m) {
Vector result(a - m.a, b - m.b);
return result;
}
template <class T>
Vector<T> Vector<T>::operator*(T m) {
Vector result(a * m, b * m);
return result;
}
template <class T>
Vector<T> Vector<T>::operator/(T m) {
Vector result(a / m, b / m);
return result;
}
}
#endif