64,682
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <vector>
#include <list>
template <class _Iter>
void Display(_Iter begin, _Iter end)
{
while (begin != end)
std::cout << *begin++ << ' ';
std::cout << std::endl;
}
#define ARRAY_LEN(X) (sizeof(X)/sizeof(X[0]))
int main ()
{
int arr[] = {1, 2, 3, 4, 5};
std::vector<int> intVector(arr, arr+ARRAY_LEN(arr));
std::list <int> intList (arr, arr+ARRAY_LEN(arr));
Display(arr, arr+ARRAY_LEN(arr));
Display(intVector.begin(), intVector.end());
Display(intList.begin(), intList.end());
return 0;
}