美文网首页
container-string-赋值

container-string-赋值

作者: 人不知QAQ | 来源:发表于2019-08-29 15:26 被阅读0次

#include<iostream>

using namespace std;

#include <string>

void  test01()

{

string str1;//默认构造

str1 = "helloworld!";

cout << "str1=" << str1 << endl;

string str2 = str1;

cout << "str2=" << str2 << endl;

string str3;

str3= 'a';

cout << "str3=" << str3 << endl;

string str4;

str4.assign("helloworld!!");

cout << "str4=" << str4 << endl;

string str5;

str5.assign("dsffsafg", 3);//前三个

cout << "str5=" << str5 << endl;

string str6;

str6.assign(str5);

cout << "str6=" << str6 << endl;

string str7;

str7.assign(10,'e');

cout << "str7=" << str7 << endl;

}

int main()

{

test01();

system("pause");

return 0;

}

相关文章

网友评论

      本文标题:container-string-赋值

      本文链接:https://www.haomeiwen.com/subject/njmiectx.html