大家讲道理2017-04-18 10:10:13
The default type of Unscoped enum is int. This enum occupies as many ints as there are on your platform.
I just wrote a program and tested it:
cholerae@Lenovo-PC:~$ cat test.cc
#include <stdio.h>
enum Genera {
INDEX = 0,
BOND = 1,
FUND = 2,
FUTURE = 3,
OPTION = 4,
WARRANT_ = 5,
STOCK = 6,
ETF = 7
};
int main() {
printf("%lu %lu\n", sizeof(Genera), sizeof(int));
return 0;
}
cholerae@Lenovo-PC:~$ ./a.out
4 4
Isn’t this the same? My system is 64-bit.