How much memory do Enums take?

后端 未结 12 1268
野性不改
野性不改 2020-12-13 06:13

For example if I have an Enum with two cases, does it make take more memory than a boolean? Languages: Java, C++

12条回答
  •  借酒劲吻你
    2020-12-13 06:24

    In C++ an enum is typically the same size as an int. That said it is not uncommon for compilers to provide a command line switch to allow the size of the enum to be set to the smallest size that fits the range of values defined.

提交回复
热议问题