In (1), main
calls go
and passes the address of foo
in the call. In (2), main
calls go
and does not pass any argument. ( foo
designates the function foo
. However, when a function designator is used in an expression other than as the operand of sizeof
or of unary &
, it is automatically converted to a pointer to the function. So go(foo)
is equivalent to go(&foo)
.)
In (1), go
takes a parameter that is a pointer to a function with unspecified parameters and return type void
. In (2), go
does not take any parameters.
In (1), go
calls the function whose address it was passed, by using its parameter proc
. In (2), go
calls foo
. (As above, although foo
is used in foo();
, it is automatically converted to an address, as if (&foo)();
had been written. All function calls actually use the address of the function, even if function designator is used.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.