6

What is the difference between the two declarations in case of foo's arguments? The syntax in the second one is familiar to me and declares a pointer to function. Are both declarations fully equivalent?

void foo(int(int));
void foo(int(*)(int));
3

1 Answer 1

7

They are equivalent as long as int(int) and int(*)(int) are used in function parameter lists. In function parameter list the int(int) is automatically adjusted by the language to mean int(*)(int).

It is the same adjustment mechanism that makes int [] parameter declaration equivalent to int * parameter declaration.

Outside of this specific context int(int) and int(*)(int) mean two different things.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! Can you elaborate on what are the two different meanings of the delcaration outside of function parameter context? Do you mean that one declares a function type and the other a pointer? I.e. something that has already been pointed out in the comments to my question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.