给定一个头文件foo.h
:
#include <bar>
// ...
还有一个文件baz.cpp
:
#include "foo.h"
// ...
是否需要将 bar
header 显式包含到 baz.cpp
中才能使用它?还是您可以开始使用它,因为它包含在 foo.h
中?
最佳答案
您需要添加 #include <algorithm>
至 main.cpp
如果main.cpp
使用任何函数或类,或在 <algorithm>
中定义的任何其他内容.
其他一些翻译单元使用什么是无关紧要的。
关于c++ - 您是否需要显式包含其他 header 已包含的 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39322657/