Today I was playing with Enum then I realized something is wrong it's mem allocation or maybe I am wrong but please tell me how an enum is able to store a 4bytes of int into a 1byte mem when I explicitly declared the type to char.
enum suit : char {club = 20,diamonds = 10,hearts = 20} card;
//driver fn
int main()
{
card = club;
cout << "Size of enum variable " << sizeof(card) << " "<<sizeof(club) <<" bytes."<<"\n";
return 0;
}
//output
Size of enum variable 1 1 bytes.