C++primer 9.5.1节练习

练习9.41

 1 #include<iostream>
 2 #include<vector>
 3 #include<list>
 4 #include <string>
 5 
 6 using namespace std;
 7 
 8 int main()
 9 {
10     vector<char> ivec{ 'h','e','l','l','o' };
11     string s(ivec.begin(), ivec.end());
12     cout << s << endl;
13     system("pause");
14     return 0;
15 }

练习9.42

用成员函数reserve去为string预先分配足够大的存储空间。

posted @ 2017-08-11 15:00  五月份小姐  阅读(219)  评论(0)    收藏  举报