Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: comp.std.c++ Subject: Re: Inheritance for enum types ??? Message-ID: Date: 27 May 91 05:39:41 GMT References: <5701@lupine.NCD.COM> Sender: davidm@cimshop.UUCP Distribution: comp Organization: Consilium Inc., Mountain View, California Lines: 34 In-reply-to: rfg@lupine.ncd.com's message of 25 May 91 07:43:08 GMT >>>>> On 25 May 91 07:43:08 GMT, rfg@lupine.ncd.com (Ron Guilmette) said: Ron> enum fruit { apple, orange, banana }; Ron> enum color { red, orange, yellow }; Ron> You can't do this because you will get an error on the (re)declaration of Ron> `orange'. Ron> Sometimes though, it would be nice to be able to do something like this, Ron> e.g. when you want to have one type which refers to a whole big range of Ron> enumerator values, and yet another type which represents some "subrange" Ron> of the larger range of enumerator values. Ron> So I was thinking... this sounds like a job for ... ta da! Inheritance! Ron> enum light_color { pink, yellow, aqua }; Ron> enum color : light_color { red, green, blue }; This is a bit confusing as you would tend to think of Light_Color as a derivative of Color, not vice versa. It would probably also be true that people would start with a general definition (Color) and later specialize it to their needs (Light_Color). Perhaps something like: enum color { pink, yellow, aqua, red, green, blue }; enum light_color : color { pink, yellow, aqua }; BTW, how hard would this be to simulate using classes? -- ==================================================================== David Masterson Consilium, Inc. (415) 691-6311 640 Clyde Ct. uunet!cimshop!davidm Mtn. View, CA 94043 ==================================================================== "If someone thinks they know what I said, then I didn't say it!"