|
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.
|