views:

88

answers:

2

hi

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

A: 

You must make the class support the IEnumerable Interface

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

Andrey
C++ has no such thing.
GMan
I'm use native C++, not managed
+3  A: 

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.

GMan
iterators is too slow (in game developing) and i don't want to use stl
@user: I do game programming, and you're horribly mistaken. Program in assembly if you're that concerned, or learn to actually program C++. I'm actually surprised people still hold such ridiculous positions, I thought that C-to-C++ wave died out long ago. Program good solid C++, don't under-estimate your compiler, profile instead of guess, and move on. Use the standard library, it's there for a reason; I can't imagine how nasty your code must look without it.
GMan