#include <iostream>
#include <vector>
using namespace std;
vector<int> myvector;
for (vector<int>::iterator it = myvector.begin();
it != myvector.end();
++it)
cout << ' ' << *it;
cout << '
';
vector<T>::iterator iteratorName;
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 << "
";
}
Code Example |
---|
Cpp :: 2d array c++ |
Cpp :: cpp pushfront vector |
Cpp :: cpp loop through object |
Cpp :: c++ power |
Cpp :: how to find the size of a character array in c++ |
Cpp :: C++ Volume of a Cylinder |
Cpp :: int main() { |
Cpp :: sqrt in c++ |
Cpp :: case label in c++ |
Cpp :: how to sort vector of struct in c++ |
Cpp :: reverse level order traversal |
Cpp :: how to declare a 2D vector in c++ of size m*n with value 0 |
Cpp :: anagram solution in c++ |
Cpp :: unique_ptr syntax |
Cpp :: max in c++ |
Cpp :: sort vector of strings |
Cpp :: string search c++ |
Cpp :: classes constructor in c++ |
Cpp :: pure virtual function in c++ |
Cpp :: c++ vector remove all duplicate elements |
Cpp :: how to print in new lines in C++ |
Cpp :: linked list in c++ |
Cpp :: count number of prime numbers in a given range in c |
Cpp :: swap in cpp |
Cpp :: template c++ |
Cpp :: c++ constructor call superclass |
Cpp :: selection sort c++ |
Cpp :: set of vectors c++ |
Cpp :: resharper fold if statement |
Cpp :: cmd color text c++ |