Click here to Skip to main content
15,949,686 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: array input using edit box Pin
Cyclone0222-Sep-06 5:59
Cyclone0222-Sep-06 5:59 
QuestionCall Windows Explorer after save files Pin
Max++21-Sep-06 5:19
Max++21-Sep-06 5:19 
AnswerRe: Call Windows Explorer after save files Pin
toxcct21-Sep-06 5:39
toxcct21-Sep-06 5:39 
QuestionDialog don't get focus back [modified] Pin
jsumm21-Sep-06 4:34
jsumm21-Sep-06 4:34 
QuestionComparing enum types Pin
Waldermort21-Sep-06 4:25
Waldermort21-Sep-06 4:25 
AnswerRe: Comparing enum types Pin
Zac Howland21-Sep-06 4:44
Zac Howland21-Sep-06 4:44 
GeneralRe: Comparing enum types Pin
Waldermort21-Sep-06 5:21
Waldermort21-Sep-06 5:21 
GeneralRe: Comparing enum types Pin
Zac Howland21-Sep-06 5:36
Zac Howland21-Sep-06 5:36 
enums in C++ are basically just named integer constants. They won't wrap around automatically. You can write your own wrapper for Enums (I actually have an article on here somewhere that makes a pretty good cut at it), or you can use const int's instead. Since you said you were coming from #define's, I would recommend using the latter.

const unsigned long NORTH = 0;
const unsigned long EAST = 1;
const unsigned long SOUTH = 2;
const unsigned long WEST = 3;

// and the function call
void myFunc(unsigned long direction)
{
	switch (direction)
	{
	case NORTH:
	case SOUTH:
	case EAST:
	case WEST:
		doSomething();
		break;
	default:
		throw exception("Oooops!");
	}
}


To make sure it is always valid, you could use your modulo operation as well.

If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: Comparing enum types Pin
Waldermort21-Sep-06 5:45
Waldermort21-Sep-06 5:45 
QuestionReceive broadcast UDP Pin
jeron121-Sep-06 4:14
jeron121-Sep-06 4:14 
QuestionRe: Receive broadcast UDP Pin
Eytukan21-Sep-06 6:17
Eytukan21-Sep-06 6:17 
AnswerRe: Receive broadcast UDP Pin
jeron121-Sep-06 7:17
jeron121-Sep-06 7:17 
QuestionTo reduce the duplication of exes Pin
johnalek21-Sep-06 3:44
johnalek21-Sep-06 3:44 
AnswerRe: To reduce the duplication of exes Pin
toxcct21-Sep-06 3:48
toxcct21-Sep-06 3:48 
QuestionRe: To reduce the duplication of exes Pin
Eytukan21-Sep-06 3:48
Eytukan21-Sep-06 3:48 
QuestionRe: To reduce the duplication of exes Pin
David Crow21-Sep-06 4:11
David Crow21-Sep-06 4:11 
QuestionLinking Error : can not select the ........... Pin
Y_Kaushik21-Sep-06 3:16
Y_Kaushik21-Sep-06 3:16 
AnswerRe: Linking Error : can not select the ........... Pin
David Crow21-Sep-06 3:18
David Crow21-Sep-06 3:18 
AnswerRe: Linking Error : can not select the ........... Pin
Eytukan21-Sep-06 3:59
Eytukan21-Sep-06 3:59 
QuestionVB application error Pin
irudayam21-Sep-06 2:40
irudayam21-Sep-06 2:40 
AnswerRe: VB application error Pin
toxcct21-Sep-06 2:47
toxcct21-Sep-06 2:47 
QuestionRe: VB application error Pin
David Crow21-Sep-06 3:04
David Crow21-Sep-06 3:04 
QuestionRe: VB application error Pin
Eytukan21-Sep-06 3:57
Eytukan21-Sep-06 3:57 
AnswerRe: VB application error Pin
Roger Stoltz21-Sep-06 4:00
Roger Stoltz21-Sep-06 4:00 
QuestionHow to fix th e windows position at startup Pin
kiranin21-Sep-06 2:31
kiranin21-Sep-06 2:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.