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

      • <bdo id='1wyAS'></bdo><ul id='1wyAS'></ul>
    1. <small id='1wyAS'></small><noframes id='1wyAS'>

      <legend id='1wyAS'><style id='1wyAS'><dir id='1wyAS'><q id='1wyAS'></q></dir></style></legend>
    2. <tfoot id='1wyAS'></tfoot>
    3. C++ 枚举是有符号的还是无符号的?

      Are C++ enums signed or unsigned?(C++ 枚举是有符号的还是无符号的?)

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

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

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

                问题描述

                C++ 枚举是有符号的还是无符号的?通过扩展,通过检查输入是否<=您的最大值,并忽略>=您的最小值(假设您从 0 开始并以 1 递增)来验证输入是否安全?

                Are C++ enums signed or unsigned? And by extension is it safe to validate an input by checking that it is <= your max value, and leave out >= your min value (assuming you started at 0 and incremented by 1)?

                推荐答案

                您不应该依赖任何特定的表示.阅读以下链接.此外,该标准还规定,使用哪种整数类型作为枚举的基础类型是实现定义的,但它不得大于 int,除非某些值不能放入 int 或无符号 int.

                You shouldn't rely on any specific representation. Read the following link. Also, the standard says that it is implementation-defined which integral type is used as the underlying type for an enum, except that it shall not be larger than int, unless some value cannot fit into int or an unsigned int.

                简而言之:你不能依赖一个有符号或无符号的枚举.

                In short: you cannot rely on an enum being either signed or unsigned.

                这篇关于C++ 枚举是有符号的还是无符号的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                What is inside .lib file of Static library, Statically linked dynamic library and dynamically linked dynamic library?(静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么?)
                How do I load a C DLL from the SXS in Python?(如何从 Python 中的 SXS 加载 C DLL?)
                Can Cython code be compiled to a dll so C++ application can call it?(Cython 代码可以编译成 dll 以便 C++ 应用程序可以调用它吗?)
                Delay Loading DLLs(延迟加载 DLL)
                Throwing C++ exceptions across DLL boundaries(跨 DLL 边界抛出 C++ 异常)
                Loading a dll from a dll?(从 dll 加载 dll?)
                    <bdo id='yHx6s'></bdo><ul id='yHx6s'></ul>

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

                        1. <tfoot id='yHx6s'></tfoot>
                        2. <small id='yHx6s'></small><noframes id='yHx6s'>

                          <legend id='yHx6s'><style id='yHx6s'><dir id='yHx6s'><q id='yHx6s'></q></dir></style></legend>