-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-8.cpp
49 lines (36 loc) · 842 Bytes
/
example-8.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
#include <iostream>
class Vector
{
public:
Vector(int _x, int _y, int _z)
: x(_x), y(_y), z(_z) {}
Vector &operator*=(const Vector &v)
{
x *= v.x;
y *= v.y;
z *= v.z;
return *this;
}
Vector &operator*=(const int scalar)
{
x *= scalar;
y *= scalar;
z *= scalar;
return *this;
}
int x;
int y;
int z;
};
int main()
{
Vector a(1, 8, 14);
Vector b(4, 85, 1);
std::cout << "a = " << a.x << " - " << a.y << " - "<< a.z << std::endl;
std::cout << "b = " << b.x << " - " << b.y << " - "<< b.z << std::endl;
a *= 45;
std::cout << "a * 45 = " << a.x << " - " << a.y << " - "<< a.z << std::endl;
a *= b;
std::cout << "a * b = " << a.x << " - "<< a.y << " - "<< a.z << std::endl;
return 0;
}