I prefer to put them in a .cpp file to speed up compilation / link time. Even tiny one-liners (empty virtual destructors!) Can explode your compilation times if they are created multiple times. In one project, I could reduce the compilation time by a few seconds by moving all the virtual destructors to .cpp files.
Since then I have been selling this, and I would only put them in the header again if the profiler tells me that I can benefit from inlining. The only drawback is that you need to type more, but if you create the .cpp file while recording the header, you can simply copy and paste the ads and fill them in the .cpp file, so it’s not so bad. Even worse, if you later find out that you want to move the material to a .cpp file.
A good side effect is that reading the material is easier when your title contains only documentation and declarations, especially if new developers join the project.
Anteru
source share