Following is my test code
#include "test.h"
#include <iostream>
typedef enum{
A = 0,
B
} testEnum;
int main()
{
testEnum e = static_cast<testEnum>(3);
printf("My enum Value : %d\n", (int)e);
int stop = 0;
}
programs out is My enum Value : 3
Now in program i am type casting number 3 into enum
and then printing it as int
. My guess way this should give error or garbage value or 1 (as enum highest value). But out put is 3. Can somebody what are the rules and how it works. Thank you!