Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!odi!benson From: benson@odi.com (Benson Margulies) Newsgroups: comp.lang.c++ Subject: Re: assigning int to enum Message-ID: <390@odi.ODI.COM> Date: 4 Jul 89 00:19:31 GMT References: <387@odi.ODI.COM> <9550@alice.UUCP> <389@odi.ODI.COM> <9552@alice.UUCP> Reply-To: benson@odi.com (Benson Margulies) Organization: Object Design Inc., Burlington, MA Lines: 19 In article <9552@alice.UUCP> ark@alice.UUCP (Andrew Koenig) writes: >At present C++ is consistent in not allowing any user-defined >conversions on built-in types. Thus instead of using an enum, >you'd have to use a class with an enum member. > I think that there is another sort of consistency problem here. If you hadn't added any type safety to the builtin types, then all would be as in plain C. However, you have added type safety restrictions to enums. To my mind, that requires controls on the type safety -- user-defined conversions. I can define conversions willy-nilly for classes. I can assign ints to shorts to longs to my heart's content. But I can neither assign an int to an enum without an explicit conversion nor can I define a conversion to obviate the need. Its like one little bit of ada (or Eiffle :-) ) in the middle of C. -- Benson I. Margulies