回答編集履歴

1

コメントを受けて修正

2017/04/15 04:48

投稿

Chironian
Chironian

スコア23272

test CHANGED
@@ -2,19 +2,19 @@
2
2
 
3
3
 
4
4
 
5
+ コメントを見て修正しました。
6
+
7
+
8
+
5
- 単純に`template<class tFunc> using FuncPointer=tFunc*`で出来るようです。
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
- FuncPointer<int(int, short)> f=&foo;
43
+ auto f=get<int(int, short)>();
38
44
 
39
45
  f(10, 5);
40
46