-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
94 lines (79 loc) · 1.29 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* @file main.cpp
* @author Mit Bailey ([email protected])
* @brief
* @version See Git tags for version information.
* @date 2021.11.03
*
* @copyright Copyright (c) 2021
*
*/
class Test
{
public:
Test()
{
for (int i = 0; i < 9; i++)
a[i] = 0;
}
Test(int x, int y)
{
a[0] = x;
a[1] = y;
}
int& operator()(int x, int y)
{
return at(x, y);
}
int& at(int x, int y)
{
int idx = x * 3 + y;
return a[idx];
}
int a[9];
};
class Test2
{
public:
int a;
bool transposed;
Test2(int x)
{
a = x;
transposed = false;
}
Test2 transpose() const
{
Test2 b(this->a);
b.transposed = !transposed;
return b;
}
void operator=(Test2 &in)
{
a = in.a;
transposed = in.transposed;
}
int operator()() const
{
return a;
}
int test()
{
return (*this)();
}
friend Test2 operator/(int x, Test2 y)
{
}
};
#include <stdio.h>
int main ()
{
Test B(10, 20);
B(0, 2) = 1901;
for (int i = 0; i < 9; i++)
printf("%d ", B.a[i]);
printf("\n");
Test2 X(10);
Test2 Y(20);
printf("%d %d\n", X.test(), X.transposed);
}