Difference between function definition and function declaration
DECLARATION
|
DEFINITION
|
A
variable or a function can be declared any number of times
|
A
variable or a function can be defined only once
|
Memory
will not be allocated during declaration
|
Memory will be allocated
|
int
f(int);
The above is a function
declaration. This declaration is just for informing the compiler that a
function named f with return type and argument as int will be used in the
function.
|
int
f(int a)
{
return a;
}
The system allocates memory by
seeing the above function definition.
|
No comments:
Post a Comment