-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmyVector.h
77 lines (72 loc) · 1.41 KB
/
myVector.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include"stdfx.h"
#include <iostream>
using namespace std;
class Vector2f
{
public:
int vCount = 2;
float vNum1;
float vNum2;
void ShowVector()
{
cout << "<" << this->vNum1 << ", " << this->vNum2 << "> " << endl;
}
Vector2f operator+(const Vector2f &u)
{
Vector2f a;
a.vNum1 = this->vNum1 + u.vNum1;
a.vNum2 = this->vNum2 + u.vNum2;
return a;
}
Vector2f operator-(const Vector2f &u)
{
Vector2f a;
a.vNum1 = this->vNum1 - u.vNum1;
a.vNum2 = this->vNum2 - u.vNum2;
return a;
}
Vector2f operator*(const float &u)
{
Vector2f a;
a.vNum1 = this->vNum1 * u;
a.vNum2 = this->vNum2 * u;
return a;
}
};
class Vector3f
{
public:
int vCount = 3;
float vNum1;
float vNum2;
float vNum3;
void ShowVector()
{
cout << "<" << this->vNum1 << ", " << this->vNum2 << ", " << this->vNum3 << "> " << endl;
}
Vector3f operator+(const Vector3f &u)
{
Vector3f a;
a.vNum1 = this->vNum1 + u.vNum1;
a.vNum2 = this->vNum2 + u.vNum2;
a.vNum3 = this->vNum3 + u.vNum3;
return a;
}
Vector3f operator-(const Vector3f &u)
{
Vector3f a;
a.vNum1 = this->vNum1 - u.vNum1;
a.vNum2 = this->vNum2 - u.vNum2;
a.vNum3 = this->vNum3 - u.vNum3;
return a;
}
Vector3f operator*(const float &u)
{
Vector3f a;
a.vNum1 = this->vNum1 * u;
a.vNum2 = this->vNum2 * u;
a.vNum3 = this->vNum3 * u;
return a;
}
};