2020
12-17
12-17
c++ STL常用遍历算法
需要引入头文件#include<algorithm>1.for_each#include<iostream>usingnamespacestd;#include<vector>#include<algorithm>classMyPrint{public:voidoperator()(intval)const{cout<<val<<"";}};voidprintVector(intval){cout<<val<<"";}voidtest(){vector<int>v1;for(inti=0;i<10;i++){v1.push_back(i);}//利用普通函数for_each(v1.begin(),v1.end(),printVector);cout<<endl;...
继续阅读 >