#include<iostream>
#include<string>
using namespace std;
//string容器构造函数
void test1() {
//默认构造函数
string s1;
const char* s = "hello world";
string s2(s);
cout << "s2=" << s2 << endl;
string s3(s2);
cout << "s3=" << s3 << endl;
string s4(10, 'a');
cout << "s4=" << s4 << endl;
}
int main() {
test1();
system("pause");
return 0;
}
string容器构造函数的四种形式
最新推荐文章于 2023-10-23 14:03:47 发布