how can *pf() and pf() be the same where pf is a pointer to the function?
They aren't the same (because of operator precedence). In case you meant (*pf)()
and pf()
are effectively the same, then that's because the rules of the language say so. Specifically, the rules say:
[expr.call]
A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses which constitute the arguments to the function.
The postfix expression shall have function type or function pointer type.
For a call to a non-member function or to a static member function, the postfix expression shall either be an lvalue that refers to a function (in which case the function-to-pointer standard conversion ([conv.func]) is suppressed on the postfix expression), or have function pointer type.
In case of (*pf)()
, the expression (*pf)
is an lvalue that refers to a function, while in the case of pf()
, the expression pf
has a function pointer type. In both cases the function pointed by pf
is called.
What is the difference between other pointers and a pointer to the function??
The primary difference is that function pointers point to functions, and pointers to objects point to objects.