C++, removing #include or #include in class header

后端 未结 12 1469
感情败类
感情败类 2021-01-03 06:37

I want to remove, if possible, the includes of both and from my class header file. Both string and vector are return types of functions declare

12条回答
  •  猫巷女王i
    2021-01-03 06:55

    Just include the header in any file where you reference an STL collection.

    As others have mentioned, there's not a way to reliably forward declare the STL classes, and even if you find one for your particular implementation, it will probably break if you use a different STL implementation.

    If the compilation units don't instantiate the classes, it won't make your object files any bigger.

提交回复
热议问题