Re: [Dev-C++] Make switch condition an enum
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Zodiaq <zo...@ac...> - 2002-10-18 12:21:41
|
Hello Daniel and all Dev-C++ users,
Friday, October 18, 2002, 1:45:12 PM, Daniel wrote as follows:
DG> Hi,
DG> I have the following chunk of code, and I've been asked to make the switch
DG> (SomeError) statement use an enum. Well I was told to "make that an enum".
DG> How would I create the enum and use it in the switch statement?
enum ERROR_TYPES { ERROR_ONE = 1, ERROR_TWO, OTHER_ERROR,
EVEN_MORE_OTHER_ERROR };
ERROR_TYPES SomeError = ERROR_TWO;
DG> // Get error strings
DG> switch (SomeError)
DG> {
DG> case ERROR_ONE:
DG> DebugOut = _T("Error One!");
DG> break;
DG> case ERROR_TWO:
DG> DebugOut = _T("Error Two!");
DG> break;
DG> default:
DG> DebugOut = _T("Unspecified error!");
DG> break;
DG> }
does it works??
--
regards, Zodiaq
|