Thread: Header files
View Single Post
Old Jun 15th, 2005, 9:21 AM   #5
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,315
Rep Power: 5 grumpy will become famous soon enough
Apart from usage of templates (few compilers support export, so the implementation has to be in the header), the most common reasons (in my experience) to put a file implementation in a header are;

1) they want the function to be inline. The compiler can potentially squeeze a bit more performance by inlining the function. YMMV, as the compiler can still decide not to inline a function (and the benefits are also compiler dependent). Simpler functions have most chance of being inlined.

2) laziness - it is easier to create one file rather than two for the same thing. If you don't care about maintainability, recompile times, etc etc.
grumpy is offline   Reply With Quote