#include <iostream>
#include <vector>
using namespace std;
vector<int> myvector;
for (vector<int>::iterator it = myvector.begin();
it != myvector.end();
++it)
cout << ' ' << *it;
cout << '
';
for(int i = 0; i < vec.size(); i++){
cout << vec[i] << endl;
}
vector<T>::iterator iteratorName;
for (auto & element : vector) {
element.doSomething ();
}
for(auto i = begin(vec); i != end(vec); i++){
cout << *i << endl;
}
}
vector<int>::iterator ptr;
for (ptr = ar.begin(); ptr < ar.end(); ptr++)
{
//do something at (*ptr)
}
vector<string> split ( const string& str ) // const-correct
{
vector<string> ret;
typedef string::const_iterator iter ;
iter i = str.begin() ;
// ...
return ret;
}
// Using a for loop with iterator
for(std::vector<int>::iterator it = std::begin(v); it != std::end(v); ++it) {
std::cout << *it << "
";
}