#include<bits/stdc++.h>
using namespace std;
void printVec(vector<int> fv){
for(int i=0;i<fv.size();i++){
cout << fv[i] << " ";
}
cout << endl;
}
void print_it_of_vec(vector<int> fv1){
vector<int> ::iterator fit;
for(fit = fv1.begin();fit != fv1.end();++fit){
cout << *fit << " ";
}
cout << endl;
}
/*
ITERATORS: Pointer like structures, helps in accessing
elements of containers(e.g. vector, array, lists, etc)
using indexation just like Pointers are used to indicate
an element in an array. Some iterators are discussed below-
###Syntax : container_name<data_type,notation accoding to the container.> ::iterator it_name;
###Purpose : To iterate through a container that doenst
support indexing, unlike vectors.
***it+1: next location.
***it++: next iterator.
1.begin(): Points to the first element;
2.end(): Points to the last element.
*/
int main(){
vector<int> v1 = {2,3,5,6,7};
printVec(v1);
vector<int> ::iterator it1 = v1.begin();
cout << "value at iterator " << *it1 << endl;
cout << *(it1 + 1) << endl;
print_it_of_vec(v1);
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZvaWQgcHJpbnRWZWModmVjdG9yPGludD4gZnYpewoJZm9yKGludCBpPTA7aTxmdi5zaXplKCk7aSsrKXsKCQljb3V0IDw8IGZ2W2ldIDw8ICIgIjsKCX0KCWNvdXQgPDwgZW5kbDsKfQp2b2lkIHByaW50X2l0X29mX3ZlYyh2ZWN0b3I8aW50PiBmdjEpewoJdmVjdG9yPGludD4gOjppdGVyYXRvciBmaXQ7Cglmb3IoZml0ID0gZnYxLmJlZ2luKCk7Zml0ICE9IGZ2MS5lbmQoKTsrK2ZpdCl7CgkJY291dCA8PCAqZml0IDw8ICIgIjsKCX0KCWNvdXQgPDwgZW5kbDsKfQovKgpJVEVSQVRPUlM6IFBvaW50ZXIgbGlrZSBzdHJ1Y3R1cmVzLCBoZWxwcyBpbiBhY2Nlc3NpbmcKZWxlbWVudHMgb2YgY29udGFpbmVycyhlLmcuIHZlY3RvciwgYXJyYXksIGxpc3RzLCBldGMpCnVzaW5nIGluZGV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