Hello,
This is a brain-dead newbie question, but here goes:
What determines what files get included in a C/C++ project?
My understanding is that the compiler starts with the file that has main() in it and that file will contain #include's to get various h files which contain #include's to other h files and so on until everything is included in the project.
My questions:
What is the relationship between h files and cpp files of the same name? I mean, of course I understand that code-wise they need each other and the cpp file always (almost always?) #include's the h file, but from the compiler's point of view is it important for them to have the same names or is this all just a convention? Can I include extra cpp files without corresponding h files?
Also, when the project is built and linked, how does it know which cpp/h files to build object files for? Will it just start at the cpp file with "main()" in it and keep going through #include's until it has everything it needs and build all of that, or does it just build everything that a user specifies in the makefile or in the IDE project file?
Finally, when the linker finally comes around and links all the object code to make an executable, is there a special order it arranges everything in?
Any help, hints, explanations appreciated.. Thanks!
--R