Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChris K
7,425 PointsWhy are some things declared before int main() and some things after the return?
I'm about 2 minutes into the video on Structs and still can't figure out (or must have missed) the location of where we declare variables/work with data. Why do certain parts of a program go before or after the int main()? Why wouldn't everything go in order after the main?
Thanks!
3 Answers
obey me
1,135 PointsI could tell you that "it is a must " for every [class ,struct, void function,and others] to be declared and implemented outside of the int main () then you could only call them inside of your main to perform action on .I hope this help
Chema Castellanos
3,984 PointsI think that for the purposes of organization he first declares things and the codes the functions that actually do things like the makeSphere function
ruo pu koh
2,669 PointsWhy is the implementing of makeSphere not inside Main(), but after it.
Chris K
7,425 PointsChris K
7,425 PointsThanks! Is there a particular order that those [class, struct, void function, etc] must be in (before/after) the int main() ?
obey me
1,135 Pointsobey me
1,135 PointsThere is no order ,just make sure you declare them then call to call them in the main .
Chris K
7,425 PointsChris K
7,425 PointsThanks!