Pe*******@gmail.com wrote:
Hi,
I have to define a composite class. I'm wondering if there are any easy
way to define its corresponding iterator class. Can I inherent the
iterator from some library?
Best wishes,
Peng
you should almost always inherit from std::iterator to have the
appropriate typedefs created for you and so that std::iterator_traits
will work for your class. but no functions are generated for you; you
have to write them yourself. however, boost (
www.boost.org) has
iterator adapter and facet (sp?) classes, which (supposably) make it
easier to create iterators (once you understand how to use them).