开发者

supporting for each loop in classes

how can i add "for each" 开发者_开发问答support for my class in c++0x and visual studio 2010?


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.


You must make the class support the IEnumerable Interface

http://msdn.microsoft.com/en-us/library/system.collections.ienumerable.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜