c++ - Limiting Scope of #include Directives -
let's have header file class uses std::string.
#include <string> class foo { std::string bar; public: // ... } the user of header file might not want std::string included in his/her project. so, how limit inclusion header file?
the user of class must include <string>, otherwise compiler not know how big foo object (and if foo's constructors/destructors defined inline, compiler won't know constructor/destructor call string member).
this indeed irritating side-effect of c++ compilation model (basically inherited intact c). if want avoid sort of thing entirely, want take @ pimpl idiom.
Comments
Post a Comment