Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/160.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;如何解释函数参数long(*pPointer)(OtherClass*const,long)?_C++ - Fatal编程技术网

C++ C++;如何解释函数参数long(*pPointer)(OtherClass*const,long)?

C++ C++;如何解释函数参数long(*pPointer)(OtherClass*const,long)?,c++,C++,我搞不懂这个语法。应该向函数传递什么?long类型的指针,或指向OtherClass实例的指针?,long到底是什么意思 在doxygen文档中,此语法解析为: long(*)(OtherClass *const, long) pPointer, 我试图搜索这种语法的示例,但很难搜索大括号和星号 它是一个指向函数的指针,该函数接受othertype和long参数并返回long。函数指针的名称为pPointer 这是一个指向名为pPointer的函数的指针(此处的命名有争议)。想象一下,在

我搞不懂这个语法。应该向函数传递什么?long类型的指针,或指向
OtherClass
实例的指针?
,long
到底是什么意思

在doxygen文档中,此语法解析为:

long(*)(OtherClass *const, long)    pPointer,

我试图搜索这种语法的示例,但很难搜索大括号和星号

它是一个指向函数的指针,该函数接受othertype和long参数并返回long。函数指针的名称为pPointer

这是一个指向名为
pPointer
的函数的指针(此处的命名有争议)。想象一下,在代码库中的某个地方有这样一个函数:

long someFunction(OtherClass *const param1, long param2);
它可以作为问题标题中的类型传递给

passFct(someFunction);
接收函数可能看起来像

void passFct(long (*pPointer) (OtherClass *const, long))
{
    /* ... */

    /* Actually call the function to with pPointer points: */
    pPointer(&otherClassInstance, 10l);
}  
一种函数(指针),它返回一个
long
,并接受类型为
OtherClass*const
long
的两个参数。