include iostream using namespace std struct myshot private int int pub

 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
#include <iostream>
using namespace std;
struct myshot{
private:
int a;
int b;
public:
myshot(){}
myshot(int a1, int b1)
{
a = a1;
b = b1;
}
int getA()
{
return a;
}
int getB()
{
return b;
}
};
myshot operator+(myshot a, myshot b)
{
int newA = a.getA() * b.getB() + a.getB() * b.getA();
int newB = a.getB() * b.getB();
return myshot(newA, newB);
}
myshot operator-(myshot a, myshot b)
{
int newA = a.getA() * b.getB() - a.getB() * b.getA();
int newB = a.getB() * b.getB();
return myshot(newA, newB);
}
myshot operator*(myshot a, myshot b)
{
int newA = a.getA() * b.getA();
int newB = b.getB() * b.getB();
return myshot(newA, newB);
}
int main()
{
myshot a(1, 2);
myshot b(2, 3);
myshot c;
c = a + b;
cout << c.getA() << c.getB();
}