0
In c++
if the function is implented in the same file .. why do I see programmers write it's definition at the top of the same file ?
2 Answers
+ 2
int add(int a, int b);
// some codes here ....
int add(int a, int b)
{
// function body
}
Were you referring to something like that? the first one is a declaration only, it is created so that its implementation can be invoked by other functions declared above the implementation, without that, the 'add' function will have to be declared before its callers before it can be used.
Hth, cmiiw
+ 2
really.. I thought order doesn't matter here .. thanx