//使用方法
str = str1 + str2;
示例代码,
#include <iostream>
using namespace std;
int main()
{
string str1 = "I'm a ", str2 = "student";
//1 字符串与字符串相加并显示
string str = str1 + str2;
cout << str << endl;
//2 字符串与字符相加并显示
str += '.';
cout << str << endl;
return 0;
}
结果为,
I'm a student
I'm a student.