在 C/C++ 中,如果我有以下函数:
void foo();
void bar(void (*funcPtr)());
这两个调用有区别吗:
bar(foo);
bar(&foo);
?
最佳答案
不,没有区别,因为函数可以隐式转换为指向函数的指针。 标准的相关报价 (N3376 4.3/1)。
An lvalue of function type T can be converted to a prvalue of type “pointer to T.” The result is a pointer to the function.
关于c++ - 函数指针需要和号吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16917043/