I'm sure this is a trivial question for the veterans (and the newbs maybe as well). But I just can't find a straight answer to it. So here it goes:
I have my main.cpp file, and 2 more files, custom.h and custom.cpp. Obviously, custom.h would contain declarations, prototype...etc, and custom.cpp would contain the actual code. So now I want to make things work together.
Now I'm sure (but if I'm wrong, please correct me) that the *.h file is included in the *.cpp file. So we have:
// custom.h /* Declarations, prototypes...etc */
// custom.cpp include "custom.h" /* Actual code */
Now, in all the examples I could find on the net, only the *.h file is included in main.cpp
// main.cpp include "custom.h" /* main function */
Now my question is: Is this correct? If so, then how does the linker figure out that it needs to link the file custom.cpp into our party? Is it just because it shares the name with the *.h file? Or is there something beyond that (which I have no idea about)?
Note: I don't have a running compiler at the moment, so it's gonna be some time before I can try anything.