Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!mips!excelan!sjsumcs!horstman From: horstman@sjsumcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Re: Conversion between enum and int Message-ID: <1989Dec23.072942.24069@sjsumcs.sjsu.edu> Date: 23 Dec 89 07:29:42 GMT References: <34022@<1989Dec18> <21000006@inmet> Reply-To: horstman@sjsumcs.SJSU.EDU (Cay Horstmann) Organization: San Jose State University Lines: 20 In article <21000006@inmet> stt@inmet.inmet.com writes: > >Presumably, you can get x = !x to work if you implement >your own operator! for Bool (and &&, || -- are those possible?). (This was in response to my query whether indeed a type conversion from int to enum Bool { FALSE, TRUE }; required a cast.) NO! You cannot attach overloaded operators to an enum, only to a class. I must say that I have been somewhat unwilling to go as far as to define class Bool { int truthValue; Bool operator!(); /* ... */ }; There are limits to everything. In fact, I am going back to good old #define FALSE 0 #define TRUE 1 #define Bool int Cay