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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -