Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!ukc!mucs!m1!bevan From: bevan@cs.man.ac.uk (Stephen J Bevan) Newsgroups: comp.std.c++ Subject: Re: Inheritance for enum types ??? Message-ID: Date: 27 May 91 19:25:16 GMT References: <5701@lupine.NCD.COM> Sender: news@cs.man.ac.uk Distribution: comp Organization: Department of Computer Science, University of Manchester Lines: 28 In-reply-to: cimshop!davidm@uunet.UU.NET's message of 27 May 91 05:39:41 GMT In article cimshop!davidm@uunet.UU.NET (David S. Masterson) writes: >>>>> On 25 May 91 07:43:08 GMT, rfg@lupine.ncd.com (Ron Guilmette) said: Ron> this sounds like a job for ... ta da! Inheritance! Ron> enum light_color { pink, yellow, aqua }; Ron> enum color : light_color { red, green, blue }; David> This is a bit confusing as you would tend to think of Light_Color as a David> derivative of Color, not vice versa. Your not alone in this thought. Cardelli and Wegner define inclusion polymorphism (or inheritance if you prefer) for variant types (enums in C++) in this way. For anyone that is interested in these sorts of issues, I recommend reading :- On Understanding Types, Data Abstraction and Polymorphism L. Cardelli and P. Wegner Computing Surveys 17(4):480-521 December 1985 and :- Type Theories and Object-Oriented Programming Scott Danfor and Chris Tomlinson Computing Surveys 20(1):29-72 March 1988 Stephen J. Bevan bevan@cs.man.ac.uk