国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

谷歌c++代碼規范(1)---命名

2019-11-06 06:49:43
字體:
來源:轉載
供稿:網友

通用命名規則

原文

Function names, variable names, and filenames should be descriptive; eschewabbreviation.Give as descriptive a name as possible, within reason. Do not worry about saving horizontal space as it is far more important to make your code immediately understandable by a new reader. Do not use abbreviations that are ambiguous or unfamiliar to readers outside your PRoject, and do not abbreviate by deleting letterswithin a Word.```一句話,就是不要擔心浪費內存空間,命名少用縮寫,語義明確才是最重要的。## 文件名 ##原文

Filenames should be all lowercase and can include underscores () or dashes (-).Follow the convention that your project uses. If there is no consistent local pattern to follow, prefer ““.

規則:字母全部小寫,可以使用下劃線‘_' 或者擴折號 '-'。另外,文件名最好多加一些定義。例如 http_server_logs.h 而不是logs.h.## 類型名 ##

Type names start with a capital letter and have a capital letter for each new word,with no underscores: MyExcitingClass, MyExcitingEnum. The names of all types — classes, structs, typedefs, and enums — have the same naming convention. Type names should start with a capital letter and have a capital letter for each new word. No underscores.

類型名包括類名,結構體,枚舉,以及typedef。其命名方式符合大駝峰法,也就是名字由一個或者多個單詞組成,每個單詞首字母大寫。## 變量名 ##

The names of variables and data members are all lowercase, with underscores between words. Data members of classes (but not structs) additionally have trailing underscores. For instance: a_local_variable, a_struct_data_member,a_class_data_member_

變量名字母全部小寫,字母間使用下劃線聯接。類成員變量需要在名稱后增加一個尾下劃線,例如 a_local_variable,而類成員變量 a_class_data_member_.## 全局變量名##

There are no special requirements for global variables, which should be rare in any case, but if you use one, consider prefixing it with g_ or some other marker to easily distinguish it from local variables.

在谷歌規范中并沒有對全局變量的具體限制,只是建議我們為全局變量起一個明顯的區別相對于其他,比如在名字前加個統一的前綴例如g_。##常量名##

Use a k followed by mixed case, e.g., kDaysInAWeek, for constants defined globally or within a class.As a convenience to the reader, compile-time constants of global or class scope follow a different naming convention from other variables. Use a k followed by words with uppercase first letters “` 常量名字的規范是混合型即前綴k+駝峰法,例如 const int kDaysInAWeek=3.


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 鲁山县| 昌乐县| 九寨沟县| 延津县| 任丘市| 华蓥市| 保亭| 太和县| 花垣县| 尉犁县| 泊头市| 班玛县| 海淀区| 琼中| 莱阳市| 盖州市| 自贡市| 洞头县| 霸州市| 孙吴县| 普兰县| 宁波市| 琼结县| 青冈县| 绍兴市| 大渡口区| 栾城县| 迁安市| 易门县| 浮山县| 馆陶县| 灵武市| 交口县| 林周县| 惠安县| 赫章县| 平潭县| 信丰县| 宜丰县| 中山市| 贵州省|