What is the difference between declaration and definition?
To explain the difference, let us consider below scenarios:
Scenario 1:
int sum(int,int,int);
Scenario 2:
int sum(int a,int b,int c)
{
return a+b+c;
}
In the Scenario 1, a function is just named and it's associated arguments (int, int, int) and return type (int) are mentioned. This scenario is called definition. Definition here does not allocate any memory and it helps the compiler to understand that there is a function defined.
In the Scenario 2, a function is fully expanded and the actual functionality has been written. This scenario is called declaration. Declaration here allocates memory to the function.
While the above two scenarios are about functions, let us consider below scenario:
0 Comments