Home  >  Q&A  >  body text

python - c++枚举类型保存为二进制文件,占多少个二进制位?

巴扎黑巴扎黑2742 days ago954

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理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.

    reply
    0
  • Cancelreply