i'm not sure if a pointer can do the job of an iterator, or otherwise, or they are different things?

Re: A pointer is an iterator, or an iterator is a pointer? 80 80

Pointers are iterators (random access iterators to be specific) and they are in fact commonly used as such. For example std::vector<T> uses T* in most (possibly all) implementations (except in the case of vector<bool>, which is a special case).

On the other hand there are many iterators that aren't pointers. For example std::list<T>::iterator could not possibly be a pointer type.

Re: A pointer is an iterator, or an iterator is a pointer? 80 80

Iterators were designed based off of pointers, so a pointer is a form of iterator, but an iterator isn't necessarily a pointer.

Re: A pointer is an iterator, or an iterator is a pointer? 80 80

they are different things?

They are different things.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.