<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++核心準則C.47:按照成員變量聲明的次序定義和初始化數(shù)據(jù)成員

          共 854字,需瀏覽 2分鐘

           ·

          2020-01-02 23:25

          20fcccda5541ec0e77d072596ce9f7f7.webp

          C.47: Define and initialize member variables in the order of member declaration

          C.47:按照成員變量聲明的次序定義和初始化數(shù)據(jù)成員


          Reason(原因)

          To minimize confusion and errors. That is the order in which the initialization happens (independent of the order of member initializers).

          最大限度降低混淆和錯誤。這(聲明的次序,譯者注)是初始化執(zhí)行的順序(和成員初始化器的順序無關)


          Example, bad(反面示例)

          class Foo {
          ? ?int m1;
          ? ?int m2;
          public:
          ? ?Foo(int x) :m2{x}, m1{++x} { } ? // BAD: misleading initializer order
          ? ?// ...
          };

          Foo x(1); // surprise: x.m1 == x.m2 == 2

          Enforcement(實施建議)

          (Simple) A member initializer list should mention the members in the same order they are declared.

          (簡單)成員初始化列表應該按照成員被聲明的次序處理它們。

          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c47-define-and-initialize-member-variables-in-the-order-of-member-declaration



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

          關注【面向對象思考】輕松學習每一天!

          面向對象開發(fā),面向對象思考!

          瀏覽 53
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <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>
                  天天久久无码一区二区三区 | 伊人中文无码 | 天天日天天操天天摸 | 国产 精品 探花 熟女 | 91爱爱网站 |