<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          C++核心準(zhǔn)則Enum.7: 只在必要時(shí)定義枚舉的底層類型

          47bc02842ac62921fa355341c4b53eff.webp

          Enum.7: Specify the underlying type of an enumeration only when necessary

          Enum.7:? 只在必要時(shí)定義枚舉的底層類型


          Reason(原因)

          The default is the easiest to read and write.?int?is the default integer type.?int?is compatible with C?enums.

          默認(rèn)的類型更容易讀寫。int是默認(rèn)的整數(shù)類型。int和C語言枚舉類型兼容。


          Example(示例)

          enum class Direction : char { n, s, e, w,
          ne, nw, se, sw }; // underlying type saves space

          enum class Web_color : int32_t { red = 0xFF0000,
          green = 0x00FF00,
          blue = 0x0000FF }; // underlying type is redundant

          Note(注意)

          Specifying the underlying type is necessary in forward declarations of enumerations:

          在前置聲明枚舉時(shí)需要定義枚舉的底層類型。


          enum Flags : char;

          void f(Flags);

          // ....

          enum flags : char { /* ... */ };

          Enforcement(實(shí)施建議)

          ????


          原文鏈接:

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#enum7-specify-the-underlying-type-of-an-enumeration-only-when-necessary




          覺得本文有幫助?請分享給更多人。

          關(guān)注【面向?qū)ο笏伎肌枯p松學(xué)習(xí)每一天!

          面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>


          瀏覽 47
          點(diǎn)贊
          評論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評論
          圖片
          表情
          推薦
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  免费18禁 | 91视频免费入口 | 国产日韩在线电影 | 人妻互换一二三区免费 | 日本无码在线 |