Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!apple!well!nagle From: nagle@well.sf.ca.us (John Nagle) Newsgroups: comp.lang.c++ Subject: Operator "++" applied to enumeration types. Summary: Is "++" allowed for enumeration types? Keywords: Zortech ++ enumeration Message-ID: <23651@well.sf.ca.us> Date: 17 Mar 91 08:31:00 GMT Distribution: comp Lines: 28 Is the operator "++" permitted on enumeration types in C++? Zortech C++ 2.1 rejects it as a request for an invalid type conversion. Zortech C 2.1 is quite happy with it, leading me to suspect this is policy, not a bug. But Strostrup's book is silent on the subject. Actually, increment and decrement on enumeration types make more sense than allowing addition of two values of the same enumeration type. Consider enum color_t {red,blue,green,yellow}; color_t lamp1, lamp2; int i; lamp1 = red; // OK lamp1++; // reasonable lamp1 = red + green; // silly,hould be an error lamp1 = red + 1; // better i = lamp1 - lamp2; // difference is logically an integer But this is probably too radical for C++. John Nagle