iterator c++
#include <iostream>
#include <vector>
int main() {
std::vector<int> numbers = {1, 2, 3, 4, 5};
// Declare an iterator to the beginning of the vector
std::vector<int>::iterator it = numbers.begin();
// Iterate through the vector using the iterator
while (it != numbers.end()) {
// Access the current element using the iterator
int currentNumber = *it;
// Display the current element
std::cout << currentNumber << " ";
// Move the iterator to the next element
++it;
}
return 0;
}