|
It is a mistake to put code into a header file. If you include that header in other files in the project, you will get multiple definitions. If you don't plan to reuse it, don't bother, just put it in the source file. If you plan to reuse it, put it in another source file and link it in. Including header files amounts to nothing but a cut-and-paste operation. If you think of it like that, perhaps you will see and understand the perils.
Building an executable involves a number of steps (which may vary, depending upon ultimate target). Among those are preprocessing (handling #includes, #defines, etc.), compiling, linking, and possibly others. It is good to have a picture in your mind of what each of these steps accomplish.
|