Do function pointers need an ampersand [duplicate]
In C/C++, if I have a the following functions:
void foo();
void bar(void (*funcPtr)());
Is there a difference between these two calls:
bar(foo);
bar(&foo);
?
No, there is no difference, since function can be implicitly converted to pointer to function. Relevant quote from standard (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.
Is there a difference between these two calls:
No, there is no difference.