Place data and the operations that perform on that data in the same class
Good
Good
#include "Good.hpp"
Good.hpp
may depend on a large number of direct and indirect include files for the data membersPointer to IMPLementation
.hpp
).cpp
)Good
PIMPLGood
PIMPL Implementationclass
or struct
. Typically, it is a struct
since there is no need to keep it private.std::unique_ptr<>
can work with incomplete types (with one issue)std::unique_ptr<>
used instead of raw pointer for RAII. I.e., don't depend on the destructor of the class to rundefault
with the destructor definition in the .cpp file so that std::unique_ptr<>
knows how to delete the incomplete type.Stack
PIMPLGood
Good