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

Recommended Answers

All 3 Replies

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.

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

they are different things?

They are different things.

Be a part of the DaniWeb community

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