Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!caen!uwm.edu!bionet!agate!stanford.edu!unix!Teknowledge.COM!uw-beaver!mit-eddie!andante!alice!ark From: ark@alice.att.com (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: Operator "++" applied to enumeration types. Keywords: Zortech ++ enumeration Message-ID: <20065@alice.att.com> Date: 18 Mar 91 18:40:38 GMT References: <23651@well.sf.ca.us> Reply-To: ark@alice.UUCP () Distribution: comp Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 16 In article <23651@well.sf.ca.us> nagle@well.sf.ca.us (John Nagle) writes: > 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. Not quite. In effect, ++x is equivalent to (x=x+1), with all the conversion rules that that implies. Now, if x is of an enumeration type, x+1 is an int, and there is no conversion from int to enum without an explicit cast. Therefore ++ cannot apply to an object of enumeration type. -- --Andrew Koenig ark@europa.att.com