C++ 标准库类型string

  string 类型在头文件 string 内,定义在 std 命名空间中。

  定义和初始化

  string s1;

  string s2(s1);  //拷贝初始化

  string s2=s1;  //同上

  string s3("hello world ");  //使用字面值初始化

  string s4(10,'c');  //使用连续10个 c 初始化

  

猜你喜欢

转载自www.cnblogs.com/wshr007/p/10440213.html