質問編集履歴
1
質問内容が不明瞭だったので弾きたい処理と場所を明確にして、意図が伝わりやすいようにReciever側をstaticに変更して、Sender側の関数はコンストラクタに変更しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,12 +1,20 @@
|
|
1
|
+
追記:質問内容が不明瞭だったので弾きたい処理と場所を明確にして、意図が伝わりやすいようにReciever側をstaticに変更して、Sender側の関数はコンストラクタに変更しました
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
1
7
|
```ここに言語を入力
|
2
8
|
|
3
|
-
class Sender{
|
4
9
|
|
5
|
-
void Send(){
|
6
10
|
|
7
|
-
|
11
|
+
class Other{
|
8
12
|
|
13
|
+
void other(){
|
14
|
+
|
15
|
+
//弾きたい処理
|
16
|
+
|
9
|
-
|
17
|
+
Receiver.Receive(new Sender());
|
10
18
|
|
11
19
|
}
|
12
20
|
|
@@ -14,11 +22,45 @@
|
|
14
22
|
|
15
23
|
|
16
24
|
|
17
|
-
class Receiver{
|
18
25
|
|
26
|
+
|
27
|
+
class Sender{
|
28
|
+
|
29
|
+
|
30
|
+
|
19
|
-
public
|
31
|
+
public Sender(){
|
32
|
+
|
33
|
+
//通したい処理
|
34
|
+
|
35
|
+
Receiver.Receive(this);
|
20
36
|
|
21
37
|
|
38
|
+
|
39
|
+
//弾きたい処理
|
40
|
+
|
41
|
+
Receiver.Receive(new Sender());
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
static class Receiver{
|
52
|
+
|
53
|
+
static public void Receive(Sender sender){
|
54
|
+
|
55
|
+
if(//引数と送ってきた側のインスタンスが一致しない){
|
56
|
+
|
57
|
+
return;
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
//メイン処理
|
22
64
|
|
23
65
|
}
|
24
66
|
|