Suppose I declared a vector C++as follows:
vector<int>numbers = {4,5,3,2,5,42};
I can iterate through the following code:
for (vector<int>::iterator it = numbers.begin(); it!=numbers.end(); it++){
// code goes here
}
Now I would like to talk about block coding for loop.
I can access and change any value using this iterator. let's say I want to increase each value by 10 and print. Thus, the code will look like this:
*it+=10;
cout << *it << endl;
I can print the address of the iterator and duplicate elements.
The iterator address can be printed:
cout << &it << endl;
The address of duplicate elements can be printed:
cout << &(*it) << endl;
But why couldn't the iterator print by doing the following:
cout << it <<endl;
At first, I thought that the convention was taken from the JAVAsecurity goal. But if so, why can I type in his address?
, ? , ?