<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)則ES.47: 使用nullptr表現(xiàn)空指針,而不是0或NULL?

          e2ab5ee993b471be59925c25dc07a3cd.webp

          ES.47: Use?nullptr?rather than?0?or?NULL

          而不是ES.47: 使用nullptr表現(xiàn)空指針,而不是0或NULL


          Reason(原因)

          Readability. Minimize surprises:?nullptr?cannot be confused with an?int.?nullptr?also has a well-specified (very restrictive) type, and thus works in more scenarios where type deduction might do the wrong thing on?NULL?or?0.

          可讀性。最小化意外性。nullptr不會混同于整數(shù)。同時nullptr具有良好定義(非常嚴(yán)格的)的類型,很多情況下使用NULL或0會導(dǎo)致類型推斷出錯,但使用nullptr就不會。


          Example(示例)

          Consider:

          考慮以下代碼:

          void f(int);
          void f(char*);
          f(0); // call f(int)
          f(nullptr); // call f(char*)
          Enforcement(實(shí)施建議)

          Flag uses of?0?and?NULL?for pointers. The transformation may be helped by simple program transformation.

          標(biāo)記使用0或者NULL表現(xiàn)指針的情況。這種變換可以或許可以通過簡單的程序進(jìn)行。


          原文鏈接

          https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es47-use-nullptr-rather-than-0-or-null




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

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

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

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

          手機(jī)掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          <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成人观看 | 精品人妻一区二区蜜桃视频 | 精品熟妇视频一区二区三区 | 丁香五月天婷国产 | 国产精品无码中文在线 |