Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Message-ID | <4F69FC1E.8090506@loria.fr> (permalink) |
|---|---|
| Date | 2012-03-21 17:04 +0100 |
| From | Jens Gustedt <jens.gustedt@loria.fr> |
| Newsgroups | comp.lang.c |
| Subject | Re: reusing identifier in two enums |
| References | <93a85ab3-ecbf-4aa0-8fbd-6699e810b9e9@v2g2000vbx.googlegroups.com> <jkbfc7$ep8$1@reader1.panix.com> |
| Organization | Guest of ProXad - France |
Am 03/21/2012 03:45 AM, schrieb Joe keane:
> In article <93a85ab3-ecbf-4aa0-8fbd-6699e810b9e9@v2g2000vbx.googlegroups.com>,
> ImpalerCore <jadill33@gmail.com> wrote:
>> I have two related but separate enumerations where I'd like to use the
>> same identifier to represent an invalid type.
>
> This is basically subtypes which define the valid values, and a
> supertype where one can only set an invalid value, and test for that.
subtype ?
> class basic_type
> {
> static const int invalid = -1;
> int x;
>
> bool is_valid() const { return x >= 0; }
> void set_invalid() { x = invalid; }
> };
>
> class color_type : basic_type
> {
> enum color { red = 1, orange = 13, yellow = 3, ... };
>
> bool is_red() const { return x == red; }
> void set_red() { x = red; }
> ...
> };
wrong language? C doesn't know anything of "class", inheritance and
things like that
> Decrement the language:
You mean C-- ?
Jens
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
reusing identifier in two enums ImpalerCore <jadill33@gmail.com> - 2012-03-19 08:04 -0700
Re: reusing identifier in two enums "Morris Keesan" <mkeesan@post.harvard.edu> - 2012-03-19 12:19 -0400
Re: reusing identifier in two enums ImpalerCore <jadill33@gmail.com> - 2012-03-19 10:43 -0700
Re: reusing identifier in two enums Keith Thompson <kst-u@mib.org> - 2012-03-19 10:43 -0700
Re: reusing identifier in two enums ImpalerCore <jadill33@gmail.com> - 2012-03-19 11:42 -0700
Re: reusing identifier in two enums jgk@panix.com (Joe keane) - 2012-03-21 02:45 +0000
Re: reusing identifier in two enums Jens Gustedt <jens.gustedt@loria.fr> - 2012-03-21 17:04 +0100
csiph-web