Limiting Scope of #include Directives
问题 Let's say I have a header file with a class that uses std::string . #include <string> class Foo { std::string Bar; public: // ... } The user of this header file might not want std::string to be included in his/her project. So, how do I limit the inclusion to just the header file? 回答1: The user of your class must include <string> , otherwise their compiler will not know how big a Foo object is (and if Foo 's constructors/destructors are defined inline, then the compiler also won't know what