NL.26: Use conventional const notation
NL.26:使用傳統的常量記法git
Reason
Conventional notation is more familiar to more programmers. Consistency in large code bases.程序員
更多的程序員熟悉常規記法。大型代碼庫的一致性。github
Example(示例)web
const int x = 7; // OK
int const y = 9; // bad
const int *const p = nullptr; // OK, constant pointer to constant int
int const *const p = nullptr; // bad, constant pointer to constant int
Note(注意)
We are well aware that you could claim the "bad" examples more logical than the ones marked "OK", but they also confuse more people, especially novices relying on teaching material using the far more common, conventional OK style.編程
咱們很清楚,您能夠說「很差的」示例比標記爲「OK」的示例更具邏輯性,可是它們還會使更多的人感到困惑,尤爲是依賴更常見,常規OK風格的教材的新手。設計模式
As ever, remember that the aim of these naming and layout rules is consistency and that aesthetics vary immensely.微信
與以往同樣,請記住,這些命名和佈局規則的目的是保持一致性,它們會帶來代碼外觀的巨大變化。架構
This is a recommendation for when you have no constraints or better ideas. This rule was added after many requests for guidance.app
當您沒有約束或更好的選擇時,能夠考慮這個個建議。此規則能夠在許多準則以後適用。ide
Enforcement(實施建議)
Flag const used as a suffix for a type.
標誌const用做類型的後綴使用的狀況。
原文連接
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#nl26-use-conventional-const-notation
新書介紹
《實戰Python設計模式》是做者最近出版的新書,拜託多多關注!
本書利用Python 的標準GUI 工具包tkinter,經過可執行的示例對23 個設計模式逐個進行說明。這樣一方面可使讀者瞭解真實的軟件開發工做中每一個設計模式的運用場景和想要解決的問題;另外一方面經過對這些問題的解決過程進行說明,讓讀者明白在編寫代碼時如何判斷使用設計模式的利弊,併合理運用設計模式。
對設計模式感興趣並且但願隨學隨用的讀者經過本書能夠快速跨越從理解到運用的門檻;但願學習Python GUI 編程的讀者能夠將本書中的示例做爲設計和開發的參考;使用Python 語言進行圖像分析、數據處理工做的讀者能夠直接以本書中的示例爲基礎,迅速構建本身的系統架構。
以爲本文有幫助?請分享給更多人。
關注微信公衆號【面向對象思考】輕鬆學習每一天!
面向對象開發,面向對象思考!
本文分享自微信公衆號 - 面向對象思考(OOThinkingDalian)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。