一、命名空间
所谓命名空间(namespace),是指标识符的各种可见范围。C++标准程序库中的所有标识符都被定义于一个名为std的命名空间(namespace)中.而我们要使用的string类也是一样的。
要使用它可以有2种方式
(1)
using namespace std
string 标识符;
(2)
std::string 标识符;
二、认识string类
string s1("abddd"); //string s1="abddd";
三、 C++标准输出流cout
string s1("abddd");
string s2;
int i=3;
//printf("%s\n",s1.data()); //char *
cout<<s1<<endl<<i<<endl<<s1.length();
#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string s1("abddd");
string s2;
int i=3;
//printf("%s\n",s1.data()); //char *
cout<<s1<<endl<<i<<endl<<s1.length();
getchar();
return 0;
}
原文链接: https://www.cnblogs.com/whzym111/p/6182465.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/245846
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!