Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!mips!excelan!sjsumcs!horstman From: horstman@sjsumcs.sjsu.edu (Cay Horstmann) Newsgroups: comp.lang.c++ Subject: Conversion between enum and int Summary: Do && || ! work on enum Bool { FALSE, TRUE }; ? Message-ID: <1989Dec18.034022.19303@sjsumcs.sjsu.edu> Date: 18 Dec 89 03:40:22 GMT Expires: 12/30/89 Sender: Cay Horstmann Reply-To: horstman@sjsumcs.SJSU.EDU (Cay Horstmann) Distribution: na Organization: San Jose State University Lines: 24 I just got around to firing up my Zortech compiler version 2.0. It flags as an *error* the following: enum Bool { FALSE, TRUE }; // ... Bool x; // ... x = !x; Is this really an error? It was my impression that conversions from enum to int and from int to enum are ok, i.e. the above should correctly work to (1) Convert x to an int (2) ! that int (3) Convert the result back to enum Bool and stuff into x I know that conversions *between* two different enums aren't ok without a cast. I sure hope I am right and Walter isn't--I *like* enum Bool { FALSE, TRUE }; and it would be pretty useless if one couldn't do && || ! on it. Hey, if I wanted fascism in enumerated types, I'd program in Ada :-) Cay