std::string是标准C++的字符串实现。为了让程序好移植,要用std::string。比如:
方法1:
#include <string>
std::string
方法2:
#include <string>
using namespace std;
string
扩展资料:
显式引入std名空间,std是c++的标准,这个名空间里面定义了很多类,如常用的string等。
如果我们使用名空间std中的类,为了防止和其他的类库名称冲突,就需要在程序中加入语句:using namespace std;
如果我们只是使用其中的一个或者几个类的话,也可以不显示引入该名空间,而是这样:std::string 也可以。
本文详细介绍了C++标准库中的字符串实现std::string,包括如何在代码中正确引入和使用std::string,以及避免命名冲突的方法。通过具体示例,展示了std::string在程序中的应用。

5665

被折叠的 条评论
为什么被折叠?



