When main.cpp is compiled the compiler generated main.obj (or main.o depending on the os). When custom.cpp is compiled the compiler generated custom.obj. The linker uses both main.obj and custom.obj, as well as other libraries, to create the executable program.
How does the linker know how to do that? It depends on the compiler and IDE you are using. With both Code::Blocks and VC++ 2010 you have to start out by creating a project then add both main.cpp and custom.cpp to that project. With olther command-line driven compilers you might have to create makefiles, which is a text file that tells the compiler and linker what to do.
No point in being any more specific until you tell us what compiler and operating system you are using.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
1) Yes that is correct
2) Its not really hidden if you look around Eclipse options -- I don't use Eclipse so I do know. Eclipse probably generates a makefile that g++ uses.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343