Quote:
Originally Posted by bob.wolff68
You talk about putting code into the .h header file. Header files are not the best place to put implementations (code). This is because there are other files which may EACH #include such a header file. When it gets included by multiple files, the implementation will be done multiple times and you'll at least get strange errors from the compiler which may be very non-obvious how to fix. Put implementation/code in .cpp files only.
|
Just a side note: It is not always bad to put implementation in a header, as long as you use
include guards. The real problem is that every time you make a change to the implementation in the header, all files that include it need to be recompiled, which can take a long time in large projects. There are some times when you are required to put implementation in a header, such as when you are using templates, but that is another topic altogether.