RE: [Dev-C++] Make switch condition an enum
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2002-10-19 11:25:54
|
The _T(x) is a macro used by a Microsoft Developer Studio, the wxWindows
framework etc, to handle wide/non-wide, characters. All you have to do is
to #define _UNICODE (or sometimes #define UNICODE, or in wxWindows
#define wxUSE_UNICODE 1) to switch all "tagged"
strings to wide character strings.
/Per W
On Sat, 19 Oct 2002, Ioannis Vranos wrote:
> > -----Original Message-----
> > From: dev...@li...
> > [mailto:dev...@li...] On Behalf
> > Of Daniel Glenfield
> > Sent: Friday, October 18, 2002 2:45 PM
> > To: dev...@li...
> > Subject: [Dev-C++] Make switch condition an enum
> >
> >
> >
> > Hi,
> > 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?
>
> Enumerators are user defined integral types taking discrete, user
> defined values. For example:
>
> // Mon=0, Tue=1, Wed=2, Thu=8, Fri=9 Sat=20 Sun=21
> enum Days { Mon, Tue, Wed, Thu=8, Fri, Sat=20, Sun};
>
>
> The above is the type. It does not occupy space the same as int, or a
> class does not occupy space by itself. Its objects do:
>
>
> Days oneday=Wed;
>
>
> switch(oneday)
> {
> case Mon:
> // ...
> }
>
>
> > // 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;
> > }
>
>
> What is that _T you are using all the time anyway? It seems to me
> something like "boxing" (as it happens in .NET for example).
>
>
>
> Ioannis
>
> * Ioannis Vranos
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL: http://run.to/noicys
>
>
>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:
> Access Your PC Securely with GoToMyPC. Try Free Now
> https://www.gotomypc.com/s/OSND/DD
> _______________________________________________
> 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
>
|