举个例子:
// base.h
#include <string>
struct base
{
virtual ~base() = default;
virtual void do_something(const std::string& arg) const = 0;
};
// derived.h
struct derived : base
{
void do_something(const std::string& arg) const
{
//...
}
};
在这个例子中应该derived.h包括string标题?
我完全同意包含您使用的内容的原则,但在这种情况下base.h必须包含string,如果界面更改为不使用string(并且include <string>相应地从 中删除base.h),那么界面无论如何都会中断突出显示。