use*_*377 5 c c++ syntax declaration
void * (*proto_type(long int, char *b)) (const char *b, unsigned short int d);
Run Code Online (Sandbox Code Playgroud)
返回类型是void*,proto_type是函数的名称?或者这是一个功能指针?哪些参数:
(long int, char *b) 或这个 (const char *b, unsigned short int d)
请解释一下这个功能是如何工作的.
void * (*proto_type(long int, char *b)) (const char *b, unsigned short int d);
Run Code Online (Sandbox Code Playgroud)
这是一个函数声明.函数名称是proto_type,它有两个类型的参数:
long intchar *并返回一个指向函数的指针
const char*unsigned short int并返回void*.
现在,如果你使用typedef,以上所有内容都将变得明显:
typedef void* function_type(const char *b, unsigned short int d);
function_type* proto_type(long int, char *b);
Run Code Online (Sandbox Code Playgroud)
希望有所帮助.
这声明proto_type为函数获取(long int, char *)和返回指向函数的指针,该函数获取(const char *, unsigned short int)并返回void指针.
换一种说法:
typedef void * (*R)(const char *, unsigned short int); // return type
R proto_type(long int, char *);
Run Code Online (Sandbox Code Playgroud)