Explain why we need both an iterator and a constiteratorSolu
Explain why we need both an iterator and a const_iterator?
Solution
Example of const_iterator:
Following is the example of the const_iterator.
vector<string>:: const_iterator it;
for (it = inventory.begin() ; it != inventory.end() ; ++it )
{
cout<<*it<<endl;
}
Example of iterator:
Following is the example of the regular iterator.
vector<string>::iterator it;
for ( it = inventory.begin() ; it != inventory.end() ; ++it )
{
cout<<*it<<endl;
}

