[자료구조] 1-05. 반복자


[자료구조] 1-05. 반복자

반복자 반복자는 객체 지향적 프로그래밍에서 배열이나 자료 구조 내부의 요소를 순회하며 접근하는 객체입니다. 예제 #include <iostream> #include <forward_list> #include <vector> using namespace std; int main() { vector<string> vec = { "lewis hamilton", "lewis hamilton", "nico roseberg", "sebastian vettel", "lewis hamilton", "sebastian vettel", "sebastian vettel", "sebastian vettel", "fernado alonso" }; auto it = vec.begin(); // 상수 시간 cout << "가장 최근 우승자: " << *it << endl; it += 8; cout << "8년 전 우승자: " << *it <<endl; advance(it, -3); // advance 는 반복...


#반복자 #자료구조

원문링크 : [자료구조] 1-05. 반복자