From 4266061415032793403
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,e422f6e841d07a08
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-03-28 02:38:31 PST
Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!news.starnet.net!wupost!news.utdallas.edu!corpgate!crchh327.bnr.ca!chaos
From: chaos@bnr.ca (Joel Schmidt)
Newsgroups: comp.std.c++
Subject: "Subclassing" Enums
Date: 27 Mar 1995 13:06:25 -0600
Organization: Bell-Northern Research, Richardson, TX
Lines: 46
Distribution: world
Message-ID: <3l72bh$8tf@crchh299.bnr.ca>
NNTP-Posting-Host: crchh299.bnr.ca


I recently found myself in a situation where I had declared an
enumeration in a base class, and then wished to "subclass" that
enumeration in a derived class, i.e:

clase base {
 enum baseEnum {
   // some values related to functionality of base class
 }
}

class derived : base {
 enum derivedEnum {
   // all values in base enum
   // plus some more associated with augmented functionality of derived class.
 }
}

The only way I could see to do this was to declare entirely new symbols
in the derived enumeration and equate them to those in the base enumeration.
This is of course both tedious and poses a maintenance nightmare.

Given the nature of class hierarchies, I think it would be quite beneficial
if you could say:

	enum derivedEnum : baseEnum {
	  // just the new symbols
	}

Along similar lines, it would also be quite useful if you could specify
a basic type as the "base", e.g:

	enum anEnum : unsigned char {}

thereby giving some control over storage size/type compatibility.  This
would also put the final nail in #define's coffin.

-- 
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~] 
[~ Joel A. Schmidt                      The reasonable man adapts himself ~]
[~ BNR, CSN Development.      to the world; the unreasonable one persists ~]
[~ I speak for myself.       in adapting the world to himself. Therefore, ~]
[~ chaos@bnr.ca           all progress depends upon the unreasonable man. ~]
[~ (214) 684-4251                                --George Bernard Shaw    ~] 
[~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~] 



