consider the following example:
typedef enum {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday} Day;
void DoSomething(Day day){
//some code
}
The problem is that the following code complies: DoSomething(74)
. So how can I check in DoSomething that my parameter is really a Day?
(relying on numbers won't work because if I change my enum like that Sunday=7
.... ,I want it to work too, and checking if(day==Sunday || day ==...)
looks inefficient).
enum
in C++11 are type-safe.stackoverflow.com/a/12581154/1809377