C++(定义和初始化string对象)

#include"stdafx.h"
#include
#include
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	string s1;
	string s2;
	string s3 = "hiya";
	string s4(10, 'c');
	string s5(s3 + s4);
	cout << s1 << endl;
	cout << s2 << endl;
	cout << s3 << endl;
	cout << s4 << endl;
	cout << (s3 + s4) << endl;
	cout << s5 << endl;

	return 0;
}

执行结果如下:

C++(定义和初始化string对象)_第1张图片








你可能感兴趣的:(C++语言)