Suppose we have an enum like the following:
enum Days {Saturday, Sunday, Tuesday, Wednesday, Thursday, Friday};
I want to crea
Rather than using a bunch of if-statements, enums lend themselves well to switch statements
I use some enum/switch combinations in the level builder I am building for my game.
EDIT: Another thing, I see you want syntax similar to;
if(day == Days.Saturday)
etc
You can do this in C++:
if(day == Days::Saturday)
etc
Here is a very simple example:
EnumAppState.h
#ifndef ENUMAPPSTATE_H
#define ENUMAPPSTATE_H
enum eAppState
{
STARTUP,
EDIT,
ZONECREATION,
SHUTDOWN,
NOCHANGE
};
#endif
Somefile.cpp
#include "EnumAppState.h"
eAppState state = eAppState::STARTUP;
switch(state)
{
case STARTUP:
//Do stuff
break;
case EDIT:
//Do stuff
break;
case ZONECREATION:
//Do stuff
break;
case SHUTDOWN:
//Do stuff
break;
case NOCHANGE:
//Do stuff
break;
}