for(auto const& value: a) {
/* std::cout << value; ... */
}
for (int i = 0; i < Vector.size(); i++)
{
type Element = Vector[i];
}
for (const auto& i : vector)
{
// do something
}
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)
}
// 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 :: unordered_map contains key |
Cpp :: zero fill in c++ |
Cpp :: c plus plus |
Cpp :: what is meant by pragma once in c++ |
Cpp :: how to delete an element in vector pair in cpp |
Cpp :: matrix dynamic memory c++ |
Cpp :: how to know the number of a certain substring in a string in c++ |
Cpp :: cuda shared variable |
Cpp :: print stack without pop c++ |
Cpp :: c++ #define |
Cpp :: size of a matrix using vector c++ |
Cpp :: vector iterating |
Cpp :: insert element in array c++ |
Cpp :: c++ client service ros |
Cpp :: find function in c++ |
Cpp :: c++ print |
Cpp :: overload subscript operator cpp |
Cpp :: Fisher–Yates shuffle Algorithm c++ |
Cpp :: rock paper scissor c++ |
Cpp :: C++ wchar_t |
Cpp :: string erase |
Cpp :: how to declare a 2d vector stack |
Cpp :: C++ cout iostream |
Cpp :: c++ custom hash |
Cpp :: for auto c++ |
Cpp :: c++ swap function |
Cpp :: or in c++ |
Cpp :: nested conditional operator |
Cpp :: phi function (n log (log(n))) |
Cpp :: if else c++ |