Pin*_*tle 3 c++ typedef function-pointers c++17
我可以
typedef int a, b;
Run Code Online (Sandbox Code Playgroud)
但我不能做类似的事情
typedef void(*the_name_1, *the_name_2)(...);
Run Code Online (Sandbox Code Playgroud)
有没有办法同时 typedef 2 个函数指针类型?
Jar*_*d42 11
C/C++ 中的多重声明具有误导性,因为*它链接到变量而不是类型:
typedef int a, *b, (*c)();
static_assert(std::is_same_v<int, a>);
static_assert(std::is_same_v<int*, b>);
static_assert(std::is_same_v<int (*)(), c>);
Run Code Online (Sandbox Code Playgroud)
所以你的一句台词是
typedef void(*the_name_1)(...), (*the_name_2)(...);
Run Code Online (Sandbox Code Playgroud)