Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Enumeration of enumerations

0 views
Skip to first unread message

Trazom

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Hi, does anyone know how to do an enumeration of differentes enumerations.
Example: enum Units{WeightUnits, TimeUnits, ...}

Thanks.

Joe Delekto

unread,
Nov 10, 2000, 3:00:00 AM11/10/00
to
Greets,

Do you mean contains them all at once? Perhaps you may want to consider
a "union" of enumerated types instead. You can have a "union Unit {}" that
can contain each type of unit. If you want to know which type of
enumeration is contained, consider a "struct" that containes and enumerated
type which defines the type of enumeration contained in the "struct" and the
union of all possible enumerations. (Try saying that 10 times fast.) :)

Regards,

Joe

"Trazom" <ferd...@bouygtel.com> wrote in message
news:167901c04b14$10b3c5a0$48862ecf@cpmsftngxa08...

Roger Onslow

unread,
Nov 12, 2000, 7:23:23 PM11/12/00
to

> Example: enum Units{WeightUnits, TimeUnits, ...}

change this to something like...

enum Units{WeightUnits, TimeUnits, ..., NumberOfUnits,
FirstUnits=WeightUnits, LastUnits = NumberOfUnits-1);

now write

for (int i = FirstUnits; i <= LastUnits; i++) {
Units u = Units(i);
...
}

alternatively, supply an appropriate operator++ for Units and you can write

for (Units u = FirstUnits; u <= LastUnits; u++) {
...
}
--
Roger Onslow
Software Developer
See my articles at http://www.codeguru.com
See the product I am working on at http://www.swishzone.com

"Operator .. give me the number for 911" .. Homer Simpson

0 new messages