Connecting Tech Pros Worldwide Help | Site Map

define new iterators

PengYu.UT@gmail.com
Guest
 
Posts: n/a
#1: Aug 18 '05
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

Alipha
Guest
 
Posts: n/a
#2: Aug 19 '05

re: define new iterators



PengYu.UT@gmail.com wrote:[color=blue]
> 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[/color]

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).

Closed Thread