enum help
Michael P.
baseball.mjp at gmail.com
Thu Aug 28 11:46:31 PDT 2008
Derek Parnell Wrote:
> On Wed, 27 Aug 2008 15:21:14 -0400, Michael P. wrote:
>
> > enum Card { NINE = 0, JACK = 2, QUEEN = 3, KING= 4, TEN = 10, ACE = 11 }
> > void main()
> > {
> > Card MyCard;
> > MyCard = NINE;
> > }
> >
> > I get an error saying that NINE is undefined ...
>
> This is because the enum declaration creates its own namespace. This is so
> you can disambiguate between different 'NINE' definitions...
>
>
> enum Card { NINE = 0, JACK = 2, QUEEN = 3, KING= 4, TEN = 10, ACE = 11 }
> enum Pin { ONE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE }
> void main()
> {
> Card MyCard;
> Pin MyPins;
> MyCard = Card.NINE;
> MyPins = Pin.NINE;
> }
>
>
> --
> Derek Parnell
> Melbourne, Australia
> skype: derek.j.parnell
Thanks, that worked.
-Michael P.
More information about the Digitalmars-d-learn
mailing list