Johan Dela
Johan Dela

Reputation: 85

Generic iterator in c++

I am busy with a project and want to know what is Generic iterator class for arrays of type T and how do i write one. I have look in books and on websites and i cant find anything on it. Please help. But dont write code for me.

Upvotes: 1

Views: 184

Answers (1)

Alex
Alex

Reputation: 7838

Probably a class that has operators unary *, ++ and possibly -- defined, where the first one returns a reference to the underlying T object, the second advances the iterator to the next element in the container and the last one advances the iterator backwards.

Or, if you're using some standard container, just the return value of yourContainer.begin() or yourContainer.find().

If you elaborate on your question you can get a better answer. For example, what container are you using? What's expecting a generic iterator?

Upvotes: 1

Related Questions