TITLE: Incrementing enumerations PROBLEM: [ This picks up on a discussion concerning operators involving enums, specifically, the increment operator. IMHO, it would be better and safer to create a class for this. -adc ] RESPONSE: grumpy@cbnewse.cb.att.com (Paul J Lucas) The correct thing to do is to overload operator++ for the enum; however, this is a very recet ANSI adoption, so your compiler won't allow it. RESPONSE: damian@cs.monash.edu.au (Damian Conway) Out of interest: 1. What was the syntax that was adopted for this? 2. What other operators can be overloaded for enums? RESPONSE: dag@control.lth.se (Dag Bruck) The same syntax as for overloading on class types; we lifted a semantic restriction because other changes to C++ (a couple of years back) solved a potential problem. Here is an example: enum Season {Winter, Spring, Summer, Fall}; Season operator ++ (Season s) { switch (s) { case Winter: return Spring; case Spring: return Summer; case Summer: return Fall; case Fall: return Winter: default: assert(0); // some garbage bits } } There are of course many other ways to implement this function. Note however that there was no need to do type casting. If you're willing to implement a large number of functions (perhaps with some automated tool), you will be able to implement bounded-range integers with enums. All operators that can be overloaded for class types [are available as enum operators].