#include<iostream>
using namespace std;
#include <string>
void test01()
{
string s1;//默认构造
const char* str = "hellworld!";
string s2(str);
cout << "s2= " << s2 << endl;
string s3(str);
cout << "s3= " << s3 << endl;//拷贝构造
string s4(10, 'q');
cout << "s4= " << s4 << endl;//拷贝构造
}
int main()
{
test01();
system("pause");
return 0;
}
网友评论