View Single Post
Old Nov 27th, 2005, 5:54 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote