Check out example codes for "declaring iterator in cpp". It will help you in understanding the concepts better.

Code Example 1

// C++ program to demonstrate iterators 
  
#include <iostream> 
#include <vector> 
using namespace std; 
int main() 
{ 
    // Declaring a vector 
    vector<int> v = { 1, 2, 3 }; 
  
    // Declaring an iterator 
    vector<int>::iterator i; 
  
    int j; 
  
    cout << "Without iterators = "; 
      
    // Accessing the elements without using iterators 
    for (j = 0; j < 3; ++j)  
    { 
        cout << v[j] << " "; 
    } 
  
    cout << "\nWith iterators = "; 
      
    // Accessing the elements using iterators 
    for (i = v.begin(); i != v.end(); ++i) 
    { 
        cout << *i << " "; 
    } 
  
    // Adding one more element to vector 
    v.push_back(4); 
  
    cout << "\nWithout iterators = "; 
      
    // Accessing the elements without using iterators 
    for (j = 0; j < 4; ++j)  
    { 
        cout << v[j] << " "; 
    } 
  
    cout << "\nWith iterators = "; 
      
    // Accessing the elements using iterators 
    for (i = v.begin(); i != v.end(); ++i)  
    { 
        cout << *i << " "; 
    } 
  
    return 0; 
}

Code Example 2

vector<int>::iterator ptr;

Learn ReactJs, React Native from akashmittal.com