#include <bits/stdc++.h>
using namespace std;
void ShowVec(const vector<int>& valList){
int count = valList.size();
for (int i = 0; i < count;i++)
{
cout << valList[i] << endl;
}
}
int main(int argc, char* argv[]){
vector<int> valList = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
ShowVec(valList);
return 0;
}
void ShowVec(const vector<int>& valList)
{
int count = valList.size();
for (int i = 0; i < count;i++)
{
cout << valList[i] << endl;
}
}
void ShowVec(const vector<int>& valList)
{
int count = valList.size();
for (int i = 0; i < count;i++)
{
cout << valList.at(i) << endl;
}
}
void ShowVec(const vector<int>& valList)
{
for (vector<int>::const_iterator iter = valList.cbegin(); iter != valList.cend(); iter++)
{
cout << (*iter) << endl;
}
}
template<typename T>
void printer(const T& val)
{
cout << val << endl;
}
void ShowVec(const vector<int>& valList)
{
for_each(valList.cbegin(), valList.cend(), printer<int>);
【参考文章:论C++11 中vector的N种遍历方法】