Though this question is about C++, but since C++ inherits typedef
and function pointer from C, so an explanation of the same question in C can be used in here. There's a formal explanation for C.
Rationale for International Standard - Programming Languages C §6.9.1 Function definitions
An argument list must be explicitly present in the declarator; it cannot be inherited from a
typedef
(see §6.7.5.3). That is to say, given the definition:typedef int p(int q, int r);
the following fragment is invalid:
p funk // weird { return q + r ; }
Some current implementations rewrite the type of, for instance, a
char
parameter as if it were declaredint
, since the argument is known to be passed as anint
in the absence of a prototype. The Standard requires, however, that the received argument be converted as if by assignment upon function entry. Type rewriting is thus no longer permissible.