C++ 提高教程 STL-构造函数

 

# include<iostream>
# include <string>
using namespace std;
//string的构造函数
void test01()
{

}
int main()
{
	string s1 = "abc";//默认构造
	const char* str = "hello world";


	
	string s2(str);

	cout << "s2:"<<s2 << endl;
	string s3(s2);
	cout << "s3:" << s3 << endl;
	string s4(10, 'a');
	cout << "s4:" << s4 << endl;
	system("pause");
	return 0;
}
全部评论

相关推荐

08-01 11:19
电气工程师
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务