是 包含时自动包含

问题描述 投票:1回答:2

这个问题显然是例如代码。很多时候,在展示std::stringstream示例时,我想如果我需要明确添加#include <string>

c++ string include
2个回答
5
投票

<sstream>标题可能包括也可能不包括<string>标题。最终它依赖于实现。在处理字符串时,您应该明确包含<string>标头,而不是依赖于依赖于实现的免费乘坐。


0
投票

不一定,没有。

std::stringstream包含了使#include <sstream>工作所需的一切。

如果你想实例化你自己的std::string#include <string>

© www.soinside.com 2019 - 2024. All rights reserved.