开发者

Ambiguous declarations

What is the difference between the following two declarations:

 1. int foo(in开发者_开发问答t); 
 2. int foo(int());

I am not sure if both the declarations are equivalent. What makes (2) different from (1)?


int foo(int); is the declaration of a function taking an integer as an argument and returning an integer as well

int foo(int()); declares a function taking as an argument "a pointer to a function returning int and taking {no arguments[in C++] and unspecified number of arguments[in C]} " and returning an integer.

(2) is equivalent to int foo(int (*pf)()) and int foo(int f())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜