If i try to compile below code it will give me error that 'enumerator value too large for underlying type 'char'
enum class Status:char{one=126,two=127,three=128};
Status s = Status::three;
However if i execute following code compiler don't give me any errors and silently ignores that char upper range is crossed
char x = 128;
So is there any specific reason why compiler don't check in case of normal data type and check for range in case of enum underlying type.
Aucun commentaire:
Enregistrer un commentaire