回答編集履歴
1
コメントを受けて修正
test
CHANGED
@@ -2,19 +2,19 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
コメントを見て修正しました。
|
6
|
+
|
7
|
+
|
8
|
+
|
5
|
-
単純に`template<class tFunc> u
|
9
|
+
単純に`template<class tFunc> tFunc* get() { return &function_name; }`で出来ます。
|
10
|
+
|
11
|
+
(function_nameに返却したい関数を記述して下さい。)
|
6
12
|
|
7
13
|
|
8
14
|
|
9
15
|
```C++
|
10
16
|
|
11
17
|
#include <iostream>
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
template<class tFunc>
|
16
|
-
|
17
|
-
using FuncPointer=tFunc*;
|
18
18
|
|
19
19
|
|
20
20
|
|
@@ -30,11 +30,17 @@
|
|
30
30
|
|
31
31
|
|
32
32
|
|
33
|
+
template<class tFunc>
|
34
|
+
|
35
|
+
tFunc* get() { return &foo; }
|
36
|
+
|
37
|
+
|
38
|
+
|
33
39
|
int main(int argc, char* argv[])
|
34
40
|
|
35
41
|
{
|
36
42
|
|
37
|
-
|
43
|
+
auto f=get<int(int, short)>();
|
38
44
|
|
39
45
|
f(10, 5);
|
40
46
|
|