On Tue, 03 Feb 2004 08:46:58 GMT, Vivi Orunitia
<Vivi@blackmagevillage.com> wrote:
[color=blue]
>As far as I can tell an iterator has all the operations of a pointer like
>deferencing *, ->, etc. which makes sense as iterators are suppose to be
>generalizations of pointers.[/color]
Right, a pointer is a model of a random access iterator. That is, a
pointer is a type of iterator.
[color=blue]
>I can imagine, however, where some operations of an iterator might not be
>implemented like ++, -- etc. if they're an iterator of a particular
>category like forward iterators, reverse iterators etc.[/color]
Right - non-bidirectional iterators don't provide --.
[color=blue]
>"Sharad Kala" <no.spam_sharadk_ind@yahoo.com> wrote in
>news:bvnlp8$uu0i2$1@ID-221354.news.uni-berlin.de:
>[color=green]
>>
>>
>> Iterator could be some other class or container::pointer.
>> In fact anything(class/pointer) that gives the notion of an iterator
>> could be an iterator to the container.
>> So one can't make assumptions that container::pointer and
>> container::iterator are actually same.
>>
>>[/color]
>
>hmm, so as far as using them is concerned under what situations would
>this difference be important? Like for example, where using ::iterator
>and ::pointer interchangably would cause potential problems etc.[/color]
When ::iterator isn't the same as ::pointer - you'll get compiler
errors. There is only one situation where they might be the same -
using std::vector with certain (mostly old) standard library
implementations. Most modern libraries have a class type for
vector::iterator. You can convert an iterator into a pointer but not
vice versa. e.g.
int* p = &*mylist.begin();
Tom
C++ FAQ:
http://www.parashift.com/c++-faq-lite/
C FAQ:
http://www.eskimo.com/~scs/C-faq/top.html