<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)則編譯邊學(xué)-F.46 main函數(shù)的返回值類型是整數(shù)

          40768cd3be7fbde2cf073b85e59cb6df.webp

          F.46: int is the return type for main()

          F.46:main函數(shù)的返回值類型是整數(shù)

          Reason(原因)

          It's a language rule, but violated through "language extensions" so often that it is worth mentioning. Declaring main (the one global main of a program) void limits portability.

          這是語言本身的準(zhǔn)則,但是由于通過“語言擴(kuò)展”的方式違反該準(zhǔn)則的情況非常常見,因此有必要提醒。將main函數(shù)(程序唯一的全局main函數(shù))定義為void會限制移植性。

          Example(示例)
          void?main()?{?/*?...?*/?};??//?bad,?not?C++
          int?main(){ std::cout << "This is the way to do it\n";}



          Note(注意)

          We mention this only because of the persistence of this error in the community.

          我們提醒這一點只是因為在社區(qū)中存在對這個錯誤的堅持。

          Enforcement(實施建議)
          • The compiler should do it

            編譯器會檢查。

          • If the compiler doesn't do it, let tools flag it

            如果編譯器不檢查,讓工具檢查。



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

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

          有任何疑問,歡迎留言提問或討論。




          面向?qū)ο笤O(shè)計,面向?qū)ο缶幊?,面向?qū)ο笏伎迹?/p>



          瀏覽 54
          點贊
          評論
          收藏
          分享

          手機(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>
                  蜜臀一二三区 | 亚洲日本一级片 | 青娱乐青青草在线观看 | 久操精品 | 天天做天天爱天天爽 |