string::append 在调用的string后面追加
return *this
c plusplus 代码:
1 // appending to string
2 #include <iostream>
3 #include <string>
4 using namespace std;
5
6 int main ()
7 {
8 string str;
9 string str2="Writing ";
10 string str3="print 10 and then 5 more";
11
12 // used in the same order as described above:
13 str.append(str2); // "Writing "
14 str.append(str3,6,3); // "10 "
15 str.append("dots are cool",5); // "dots "
16 str.append("here: "); // "here: "
17 str.append(10,'.'); // "."
18 str.append(str3.begin()+8,str3.end()); // " and then 5 more"
19 str.append<int>(5,0x2E); // ".."
20
21 cout << str << endl;
22 return 0;
23 }