回答編集履歴
1
説明の追加
test
CHANGED
@@ -71,3 +71,51 @@
|
|
71
71
|
f1 (a = 20, x = hello)
|
72
72
|
|
73
73
|
```
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
以下追記
|
78
|
+
|
79
|
+
C/C++ の宣言は関数ポインターが絡むと非常にややこしくなりますね。
|
80
|
+
|
81
|
+
maisumakun さんの回答のように `auto` を使って変数を定義しておき `typeid` で型を表示させれば一発でわかります。
|
82
|
+
|
83
|
+
```C++
|
84
|
+
|
85
|
+
#include <iostream>
|
86
|
+
|
87
|
+
#include <string>
|
88
|
+
|
89
|
+
#include <typeinfo>
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
void func4(void(*fp)(void(*)(int a, std::string x)), int b)
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
int main() {
|
102
|
+
|
103
|
+
auto fp = func4;
|
104
|
+
|
105
|
+
std::cout << typeid(fp).name() << '\n';
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
```
|
110
|
+
|
111
|
+
VC++ で実行すると
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
void (__cdecl*)(void (__cdecl*)(void (__cdecl*)(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)),int)
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
`std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >` は `std::string` ですから、結局 `void (__cdecl*)(void (__cdecl*)(void (__cdecl*)(int,std::string)),int)` となり、`__cdecl` を削除すれば `void (*)(void (*)(void (*)(int,std::string)),int)` となります。
|