<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)則C.162:將大致相同的操作設(shè)計(jì)為重載函數(shù)?

          1781407a244560afe30c2d584613edf7.webp

          C.162: Overload operations that are roughly equivalent

          C.162:將大致相同的操作設(shè)計(jì)為重載函數(shù)


          Reason(原因)

          Having different names for logically equivalent operations on different argument types is confusing, leads to encoding type information in function names, and inhibits generic programming.

          邏輯上等價(jià),只是參數(shù)不同的操作具有不同的名稱是難以理解的,會(huì)導(dǎo)致函數(shù)名中包含類型信息,而且阻礙編程共通化。


          Example(示例)

          Consider(考慮下面的代碼):

          void print(int a);
          void print(int a, int base);
          void print(const string&);

          These three functions all print their arguments (appropriately). Conversely:

          這三個(gè)函數(shù)都(恰當(dāng)?shù)?打印參數(shù)指定的內(nèi)容。相反地,

          void print_int(int a);
          void print_based(int a, int base);
          void print_string(const string&);

          These three functions all print their arguments (appropriately). Adding to the name just introduced verbosity and inhibits generic code.

          這三個(gè)函數(shù)都(恰當(dāng)?shù)?打印參數(shù)指定的內(nèi)容。只是在函數(shù)名中增加了冗長的,阻礙共通化編程的信息。


          Enforcement(實(shí)施建議)

          ???



          原文鏈接:

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c162-overload-operations-that-are-roughly-equivalent



          覺得本文有幫助?請(qǐng)分享給更多人。

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

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

          瀏覽 26
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          <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>
                  天堂网中文字幕 | 男女WWWWWWWWW | 亚洲高清免费观看视频 | 特级特黄A片一级一片 | 日韩一级黄片免费看 |