enumeration typed objects


Subject: enumeration typed objects
From: Sundeep Paliwal (sundeep@0-in.com)
Date: Fri Dec 06 2002 - 16:40:50 PST


Hi,
   I was following the clarifications on enum type and felt that the enum declaration
should have a closed and spill over value system specification. You might need a wrap
around or spill over value system depending on your specific need. Putting a check
like the one below can be avoided if we have two modes of enum type declaration.

// code you need to write to wrap around
 if ( c == green )
   c = red ;
 else
   c++;

 Declaration with keyword closed:
----------------------
 enum closed Colors = {red, blue, green};
 Colors c: // c defaults to first enum value red
 c++++++; // c becomes red

Declaration without keyword defaults to spill over:
--------------------------------
enum Colors = {red, blue, green};
Colors c: // c defaults to undefined
c = red;
c++++++; // run time error

Sundeep

Kevin Cameron x3251 wrote:

> > From: "Francoise Martinolle" <fm@cadence.com>
> >
> > What is the defasult value of a object (variable) defined of an enumeration type.
> >
> > Let's assume enum Colors = {red, blue, green};
> > Colors c;
> > What is the value of c?
> >
> > I don't see it specified in the standard.
> >
> > Francoise
> > '
>
> Since we're doing runtime checking it should probably be undefined (out-of-range),
> so that it has to be set before use.
>
> Kev.



This archive was generated by hypermail 2b28 : Fri Dec 06 2002 - 16:41:51 PST