Posted by: shmuklidooha
Posting time: 4.5 years ago on
Last edit time: never edited.
Archived on: 2/12/2017 1:51:00 AM
Views: 469
SCP: 5
5 upvotes, 0 downvotes (100% upvoted it)
~1 user(s) here now
NSFW: No
Authorized: No
Anon: No
Private: No
Type: Default
view the rest of the comments →
[–] DrBunsen 0 points 1 point 1 point (+1|-0) ago (edited ago)
Anything that is underneat the main, doesn't get loaded in and has to be loaded into the memory to be able to be used. That is what
is doing, saying we got an int returning function called add, and it uses 2 parameters that are ints.
[–] shmuklidooha [S] ago
Yeah, but why not just define the whole add(){} function at the start?
[–] ghost_marauder 0 points 1 point 1 point (+1|-0) ago
This prevents issues for the compiler during cyclic definitions
int f(int a){return g(a);}
int g(int a){return f(a);}
will spit out an error saying stuff was not declared.
int f(int a);
int g(int a);
int f(int a){return g(a);}
int g(int a){return f(a);}
will have no compiler issues. This is a leftover from the days when compilers didn't do any backtracking.
[–] DrBunsen 0 points 1 point 1 point (+1|-0) ago
I don't know, I declare all my functions before to main to avoid doing this, but whatever floats your boat I guess.