In the class definition header file
usually if your build time is more important (assuming this is not the case, based on the question). the exception follows
At the end of the header file
rarely. I deal with nasty patterns just to clean things up. the body is usually so small that it does not distract, and this can lead to implementation details (as a substitute for documentation, but I believe that some people will force me to do so). Example:
void compute() { assert(this->hasEnoughEnergyToCompute()); ...computing }
In some cases, this approach may be good hygiene. I actually used secondary files for this (fourth option).
In source file
this option is ideal - if it appears in every translation where you name it. otherwise send it back to the header.
In this case, should you use the keyword inline or extern inline?
just 'inline'. in fact, your compiler probably declares inline methods implicitly. omit it completely if all your required compilers support this.
source share