Should I use header-only classes or lib files?
I am creating an external library for general use. What Im asking is should I put every class in just .hpp files like boost does or should I compile it into a lib file and keep the two file per class rule. As far as I can see .hpp is used for speed, so you don't have to add a .lib for every class or a massive one for the whole thing and for cross-platform.
[edit] Whats your personal preference and why. My library would just be for my per开发者_开发问答sonal use. [edit] For statically linking the library
For a class that is used in multiple compilation units (cpp-files) you will want to have as tiny header files as possible to keep down the build time. The bulk of your code should go into a cpp file.
This really depends on if you have cross-platform or templated code. You may not have an awful lot of choice about making the majority in header files if you need a lot of preprocessing to generate it. Otherwise, you should pre-compile as much as possible, as a general rule.
精彩评论