C++ 規範 自己參考

來源:互聯網
上載者:User
01./* 檔案名稱: MyClass.h  02. * 摘    要:  03. *  04. * 目前的版本:  05. * 作    者:  06. * 完成日期:  07. *  08. * 更新說明:  09. *  10. */  11.   12. #ifndef MYCLASS_H_  13. #define MYCLASS_H_  14.   15. #include <string>            //標準庫標頭檔  16.   17. #include "other.h"         //自訂標頭檔  18.   19. int  g_initValue;          /全域變數以g_開頭。  20. const  int  MAX = 100;     //常量應該全部大寫。  21.   22. struct MyStruct            //全域結構體聲明  23. {  24.    int num;  25.    string name;  26.    string address  27. };  28.   29. void AddNumber(void);          //函數名應使用動詞或動詞+名詞。首字母大寫,用大寫隔開。無參數的要用void填充。  30.   31. class MyClass                  //類聲明,類名首字母大寫,用大寫隔開。  32. {  33.    public:  34.        int AddArea(int width, int height);       35.  36.    private:                        //建議將變數聲明放在後面,以“行為”為中心,使用者關心的是介面。  37.        enum{SIZE = 100, SIZET = 200};  //枚舉常量  38.        int  m_width;             39.        int  m_height;              //類的資料成員以m_開頭。避免資料成員與成員函數參數同名。  40.        static int s_initValue;     //靜態變數用s_開頭。  41.          42. };  43.  44. #endif</span>  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.