hi
how can i add "for each" support for my class in c++0x and visual studio 2010?
hi
how can i add "for each" support for my class in c++0x and visual studio 2010?
You must make the class support the IEnumerable Interface
http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx
I think the best way would be to add iterator support, with begin()
and end()
functions. The ranged-based for-loop uses them, and this also gives your class the richer set of functionality iterators provide.