如何在cpp中导入/包含字符串

Rhe*_*hee 0 c++ namespaces include

我想使用字符串类。我还应该参与using namespace std;吗?

我以为#include <string>就足够了,但是在CLion中,只有这两个(命名空间或包含)之一不存在时,会出现一些错误。

使事情变得更复杂的是存在<string><strings.h>。有什么不同?

Mat*_*her 5

<string>是C ++,并提供了std::string此类。

<string.h>是C(与C ++等价<cstring>),并且仅提供要使用的函数char*

不要使用using namespace std;(请参阅C ++核心准则)。