<tfoot id='dCgmG'></tfoot>

    1. <legend id='dCgmG'><style id='dCgmG'><dir id='dCgmG'><q id='dCgmG'></q></dir></style></legend>
    2. <i id='dCgmG'><tr id='dCgmG'><dt id='dCgmG'><q id='dCgmG'><span id='dCgmG'><b id='dCgmG'><form id='dCgmG'><ins id='dCgmG'></ins><ul id='dCgmG'></ul><sub id='dCgmG'></sub></form><legend id='dCgmG'></legend><bdo id='dCgmG'><pre id='dCgmG'><center id='dCgmG'></center></pre></bdo></b><th id='dCgmG'></th></span></q></dt></tr></i><div id='dCgmG'><tfoot id='dCgmG'></tfoot><dl id='dCgmG'><fieldset id='dCgmG'></fieldset></dl></div>

      <small id='dCgmG'></small><noframes id='dCgmG'>

      • <bdo id='dCgmG'></bdo><ul id='dCgmG'></ul>

      c++ 枚举的底层类型是什么?

      时间:2023-08-29

      1. <tfoot id='aTdar'></tfoot>
              <i id='aTdar'><tr id='aTdar'><dt id='aTdar'><q id='aTdar'><span id='aTdar'><b id='aTdar'><form id='aTdar'><ins id='aTdar'></ins><ul id='aTdar'></ul><sub id='aTdar'></sub></form><legend id='aTdar'></legend><bdo id='aTdar'><pre id='aTdar'><center id='aTdar'></center></pre></bdo></b><th id='aTdar'></th></span></q></dt></tr></i><div id='aTdar'><tfoot id='aTdar'></tfoot><dl id='aTdar'><fieldset id='aTdar'></fieldset></dl></div>

              <small id='aTdar'></small><noframes id='aTdar'>

              • <bdo id='aTdar'></bdo><ul id='aTdar'></ul>
                <legend id='aTdar'><style id='aTdar'><dir id='aTdar'><q id='aTdar'></q></dir></style></legend>

                  <tbody id='aTdar'></tbody>
                本文介绍了c++ 枚举的底层类型是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                这可能在别处得到了回答,但我找不到合适的回答.

                This may have been answered elsewhere but I could not find a suitable response.

                我有这个代码:

                enum enumWizardPage
                {
                    WP_NONE = 0x00,  
                    WP_CMDID = 0x01,    
                    WP_LEAGUES = 0x02,  
                    WP_TEAMS = 0x04,    
                    WP_COMP = 0x08, 
                    WP_DIVISIONS = 0x10,
                    WP_FORMULAS = 0x20, 
                    WP_FINISHED = 0x40, 
                };
                

                这是遗留问题,我必须通过添加一些新值来修改它.问题是每个值必须是唯一的位,以便它们可以或组合成位图.

                Which is legacy and I have to modify it by adding a few new values. The issue is each value must be a unique bit so they may be OR combined to a bitmap.

                这些值是使用 #x## 十六进制格式设置的,但我想知道这是否是它可以存储的最大值?如果我将代码更改为

                The values are set using the #x## hex format, but I'm wondering if this is the max it can store? What will be the effect, if any, if I change my code to

                enum enumWizardPage
                {
                    WP_NONE = 0x0000,  
                    WP_CMDID = 0x0001,  
                    WP_LEAGUES = 0x0002,    
                    WP_TEAMS = 0x0004,  
                    WP_COMP = 0x0008,   
                    WP_DIVISIONS = 0x0010,
                    WP_FORMULAS = 0x0020,   
                    WP_FINISHED = 0x0040,   
                };
                

                推荐答案

                来自 N4659 C++ 7.2/5:

                对于底层类型不固定的枚举,底层类型为整型,可以表示枚举中定义的所有枚举器值.如果没有整数类型可以表示所有枚举器值,则枚举格式错误.使用哪种整数类型作为底层类型是实现定义的,除非底层类型不应大于 int,除非枚举数的值不能放入 intunsigned int.如果 enumerator-list 为空,则底层类型就好像枚举有一个值为 0 的枚举器.

                For an enumeration whose underlying type is not fixed, the underlying type is an integral type that can represent all the enumerator values defined in the enumeration. If no integral type can represent all the enumerator values, the enumeration is ill-formed. It is implementation-defined which integral type is used as the underlying type except that the underlying type shall not be larger than int unless the value of an enumerator cannot fit in an int or unsigned int. If the enumerator-list is empty, the underlying type is as if the enumeration had a single enumerator with value 0.

                这篇关于c++ 枚举的底层类型是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:什么是 C++ 中的标量对象? 下一篇:我是否必须使用 #include &lt;string&gt;在 &lt;iostream&am

                相关文章

                <legend id='A3w2j'><style id='A3w2j'><dir id='A3w2j'><q id='A3w2j'></q></dir></style></legend>
              • <tfoot id='A3w2j'></tfoot>
                <i id='A3w2j'><tr id='A3w2j'><dt id='A3w2j'><q id='A3w2j'><span id='A3w2j'><b id='A3w2j'><form id='A3w2j'><ins id='A3w2j'></ins><ul id='A3w2j'></ul><sub id='A3w2j'></sub></form><legend id='A3w2j'></legend><bdo id='A3w2j'><pre id='A3w2j'><center id='A3w2j'></center></pre></bdo></b><th id='A3w2j'></th></span></q></dt></tr></i><div id='A3w2j'><tfoot id='A3w2j'></tfoot><dl id='A3w2j'><fieldset id='A3w2j'></fieldset></dl></div>
                  <bdo id='A3w2j'></bdo><ul id='A3w2j'></ul>

                <small id='A3w2j'></small><noframes id='A3w2j'>