[Tutor] enumeration in C++

alan.gauld@bt.com alan.gauld@bt.com
Tue, 2 Apr 2002 13:44:28 +0100


> | Depends on which bit of C++ enums you want to use, 
>  
> | If you need an autoincrementing list of consts 
> 
> The value of a label in an enum is undefined (at least in C).  

Original K&R C didn't have enums at all.
In ANSI C they exist but values are implicit.

But not in C++....

You can do:

enum foo = {alpha=5,		// = 5
            beta,			// = 6
		gamma = 12,		// = 12
            delta,		// = 13
		epsilon,		// = 14
		omega};		// = 15

And the standard says the default first value is zero.

Alan g.