2013/8/1 Jon Cruz <jon@...18...>:
Another general problem with bodies in headers is that if they are not trivial then they need to pull in other includes to be able to do their job. That 'contaminates' consumer .cpp files with more includes than absolutely necessary. Compile times for the project then go up.
This is a legitimate issue, but it is only relevant in this case:
#include <big-object.h> #include <mammoth-object.h> #include <gargantuan-object.h>
class SimpleClass { public: ... private: BigObject _x; MammothObject _y; GargantuanObject _z; };
Instead of hiding the three member objects in a pimpl, one can convert _x, _y and _z to pointers, in which case only forward declarations are necessary. This is more readable, because one doesn't need to track down the definition of the pimpl structure to know the members of the class.
Regards, Krzysztof