In C or C++ what is the difference between function declaration and function signature?
I know something of function declaration but function signature is totally ne
A function declaration is a prototype. A function signature indicates what is the return type and the parameters used that makes up the signature. Consider this:
int foo(int, int); /* Function Declaration */ /* Implementation of foo ** Function signature */ int foo(int a, int b){ }
Now, consider this scenario: a programmer is asked what is the function signature for foo
:
int
int
, named a
and b
respectivelyThe function prototype on the other hand is to clue in the C/C++ compiler, on what to expect and if the signature does not match up with the prototype, the compiler will emit an error, along the context of 'function declaration error' or 'prototype mismatch'.