Unnamed Namespaces Replace File Statics

點閱人數:62次 九月 17th, 2008 by ㄚ琪 | 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

C++ Primer 4/e在Namespaces這個地方有一段說明:『Prior to the introduction of namespaces in standard C++, programs had to declare names as static to make them local to a file. The use of file statics is inherited from C. In C, a global entity declared static is invisible outside the file in which it is declared.

警告

The use of file static declarations is deprecated by the C++ standard. A deprecated feature is one that may not be supported in future releases. File statics should be avoided and unnamed namespaces used instead.』

中文版的這樣寫:『標準C++引入namespace之前,程式必須將某個名稱宣告為static才能使它區域化(local to)於檔案內。這種性質繼承自C語言。在C語言中,宣告為static的global物體,在其所處檔案之外是不可見的。

警告

C++不贊成使用file static變數宣告。這意味C++將來有可能不再支援此一特性。』

還好我static也很少用。

喜歡這篇文章嗎?請幫這篇加入共用書籤,謝謝:
  • Digg
  • del.icio.us
  • Google Bookmarks
  • Hemidemi
  • MyShare
  • Technorati
  • StumbleUpon
  • Diigo
  • Facebook
  • Twitter

Random Posts

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

發表迴響

名稱:(必)
電子郵件位址(並不會被公開)(必)
個人網站


Fatal error: Call to undefined function cbnet_comment_captcha() in /home/job/public_html/wp-content/themes/achi/comments.php on line 84