[Cs3] Question on Code
Mikhail Nesterenko
mikhail at cs.kent.edu
Fri May 2 21:06:58 EDT 2014
> So this must always be done to output what iterators refer to?
>
To output what iterator refers to, you need to dereference it like so:
auto it = vect.begin():
cout << *it;
Now, if you want to output the _position_ of the element in the
vector, then you can subtract the iterator from the beginning of the
vector iterator. For example
cout << it - vect.begin();
would output 0 because both iterators would point to the first element
in the vector.
Thanks,
--
Mikhail
More information about the cs3
mailing list