支持类中的每个循环 [英] supporting for each loop in classes

查看:105
本文介绍了支持类中的每个循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c ++ 0x和visual studio 2010中为我的类添加for each支持?

how can i add "for each" support for my class in c++0x and visual studio 2010?

推荐答案

我认为最好的方法是添加迭代器支持, begin() end()函数。基于范围的for-loop使用它们,这也为您的类提供了更丰富的迭代器提供的功能集。

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.

这篇关于支持类中的每个循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆