将上一题刚刚创建的数组拷贝给另外一个数组。利用vector重写程序,实现类似的功能
# include <iostream> # include <vector> # include <string> using namespace std; using std::vector; int main() { int arr[5] = { 1,2,3,4,5 }; vector<int>v; for (auto i:arr)//数组也可以 v.push_back(i); vector<int>v2 = v; for (auto a : v2) cout << a << endl; cout << endl; return 0; }
C++ Primer 3.32
猜你喜欢
转载自blog.csdn.net/Jason6620/article/details/88317633
今日推荐
周排行