-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMajmoue.cpp
69 lines (58 loc) · 1.08 KB
/
Majmoue.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
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream.h>
#include <conio.h>
class majmoue
{
int data[2];
public:
majmoue (int, int);
void set(int,int);
void print();
friend majmoue operator+(majmoue,majmoue);
friend majmoue operator*(majmoue,majmoue);
};
majmoue::majmoue (int a1, int a2)
{
data[0] = a1;
data[1] = a2;
}
void majmoue::set (int a1, int a2)
{
data[0] = a1;
data[1] = a2;
}
void majmoue::print()
{
cout << " "<<data[0]<<", "<<data[1]<<"\n\n";
}
majmoue operator+(majmoue m1,majmoue m2)
{
majmoue m3(0,0);
m3.set(m1.data[0] + m2.data[0],
m1.data[1] + m2.data[1]);
return m3;
}
majmoue operator*(majmoue m1,majmoue m2)
{
majmoue m3(0,0);
m3.set(m1.data[0] * m2.data[0],
m1.data[0] * m2.data[1]);
return m3;
}
int main()
{
majmoue m1(5,2);
majmoue m2(2,3);
majmoue m3(0,0);
cout << "majmoue1:" << endl;
m1.print();
cout << "majmoue2:" << endl;
m2.print();
m3=m1+m2;
cout << "\n\nSum(+):" << endl;
m3.print();
m3 = m1*m2;
cout << "Mul(*):" << endl;
m3.print();
getch();
return 0;
}