myschu
myschu

Reputation: 91

Ambiguous function declaration

I have such code:

int fun(int());

What does it exactly do? As far as I know it is equivalent to declaration of function taking pointer to function

int fun(int (*ptr)())

but I'm not sure why.

Upvotes: 0

Views: 157

Answers (1)

M.M
M.M

Reputation: 141633

These are all the same:

int f( int()     );
int f( int(*)()  );
int f( int(*p)() );
int f( int p()   );
int f( int(p)()  );
  • There is a language rule that if you declare a function parameter as having function type, it is adjusted to having function pointer type.
  • The name of a parameter can be omitted.

Upvotes: 5

Related Questions