where should “include” be put in C++

后端 未结 9 2022
生来不讨喜
生来不讨喜 2020-12-14 16:06

I\'m reading some c++ code and Notice that there are "#include" both in the header files and .cpp files . I guess if I move all the "#include" in the fi

9条回答
  •  渐次进展
    2020-12-14 16:27

    There's nothing wrong with using #include in a header file. It is a very common practice, you don't want to burden a user a library with also remembering what other obscure headers are needed.

    A standard example is #include . Gets you the vector class. And a raft of internal CRT header files that are needed to compile the vector class properly, stuff you really don't need nor want to know about.

提交回复
热议问题