Re: [Dev-C++] Make switch condition an enum
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2002-10-18 16:04:19
|
Thanks.
A motorcycle helmet?
>From: "Abhijit Shylanath" <mu...@gm...>
>To: "Daniel Glenfield"
><sp...@ho...>,<dev...@li...>
>Subject: Re: [Dev-C++] Make switch condition an enum
>Date: Fri, 18 Oct 2002 20:11:00 +0530
>
> > I have the following chunk of code, and I've been asked to make the
>switch
> > (SomeError) statement use an enum. Well I was told to "make that an
>enum".
> >
> > How would I create the enum and use it in the switch statement?
> >
> >
> > // Get error strings
> > switch (SomeError)
> > {
> > case ERROR_ONE:
> > DebugOut = _T("Error One!");
> > break;
> >
> > case ERROR_TWO:
> > DebugOut = _T("Error Two!");
> > break;
> >
> > default:
> > DebugOut = _T("Unspecified error!");
> > break;
> > }
>
>Something like this:
>
>enum ErrorType { ERROR_ONE = 1, ERROR_TWO }
>
>and then the same code with SomeError being of type ErrorType rather than
>int (as I assume it is here).
>
>
>For those of you who are interested, a helmet saved my life yesterday,
>after
>a crash at 90 kph.
>
>___________________________________________________________
>
>Abhijit Shylanath
>
>E-mail: mu...@gm... || ibr...@bi...
>Web-site: http://mudeth.tripod.com/
>
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by:ThinkGeek
>Welcome to geek heaven.
>http://thinkgeek.com/sf
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.asp
|