개발
modern C++ begin/end
jmob_blog
2019. 12. 15. 22:30
728x90
반응형
- begin(), end() 함수 사용
#include <iostream>
#include <vector>
#include <list>
#include <iterator>
using namespace std;
template<typename T> void show (T& c)
{
auto p1 = begin(c);
auto p2 = end(c);
while (p1 != p2)
{
cout << *p1 << endl;
++p1;
}
}
int main()
{
list<int> a = {1, 2, 3};
vector<int> b = {1, 2, 3};
int c[3] = {1, 2, 3};
show(a);
show(b);
show(c);
}
728x90
반응형