   why do enums don't support ++?
  I don't know if this is VC6 problem, but it's difficult to iterate through the enums if = operator is all you have.Do you have tips&tricks to do the same?edit: other than writing an enum class, I would do it but not on this project.[edited by - alnite on February 9, 2004 10:15:11 PM]
  Well... uh... i kinda thought enums were supposed to be constant... ;  Well, instead of using the enum as a type, you can use a variable of type int, and set it to the enum''s values. The compiler should be fine with that. ;  well, right, but it would be convenient to be able to go through the enums. for example:enum Direction{   Left,   Top,   Right,   Bottom,};Direction dir;for ( ;; )   dir++;   // will go, left, top, right, bottom, left, top, right, ...  ;quote:Original post by pinacolada  Well, instead of using the enum as a type, you can use a variable of type int, and set it to the enum''s values. The compiler should be fine with that.   But it doesn''t check boundary, does it? if the last enum''s value is for example 6, ++ an int will make it 7. ;enum Direction{Left,Top,Right,Bottom,};int dir;for ( ;; )dir++;  // will go, left, top, right, bottom, left, top, right, ...will work great ;quote:Original post by alnite  But it doesn''t check boundary, does it? if the last enum''s value is for example 6, ++ an int will make it 7.   Nope it doesn''t, sorry. ;  damn, I should have foreseen this.Well...here goes the if statements. ;struct _direction{unsigned int w : 2;operator unsigned int() { return w; }void operator=(unsigned int a) { w = a; }unsigned int operator++() { ++w; return w; }unsigned int operator++(int) { unsigned int a = w; ++w; return a; } } direction;enum _directions{up, down, left, right,};int main(){direction = down;for (int i = 0; i < 10; i++)cout << direction++ << endl;return 0;}might do the trick...   blah blah blah. ;  sorry about the last post...i ran into this problem before...there isnt really a good solution to it   [edited by - m3ssiah on February 9, 2004 10:51:19 PM]