What is the difference between these 2 declaration:
int operate(int (*func)(int, int), int a, int b){
return (*func)(a, b);
}
and
int operate(int func(int, int), int a, int b){
return func(a, b);
}
These two also seems to be equivalent: operate(sum, 1, 1) and operate(&sum, 1, 1)
If I pass function sum as a function of 2 numbers in the place of func, the result are still the same. Why?
§6.7.5.3/8:
In other words, the two function declarations are identical.
As far as the function call goes, §6.5.2.2/3:
Since both
func(a, b);and(*func)(a, b)are postfix expressions followed by parentheses, they’re both function calls. Sincefuncand(*func)both designate the same function, they both call the same function.