C++核心準則?NL.26:使用傳統(tǒng)的常量記法

NL.26: Use conventional?const?notation
NL.26:使用傳統(tǒng)的常量記法
Reason
Conventional notation is more familiar to more programmers. Consistency in large code bases.
更多的程序員熟悉常規(guī)記法。大型代碼庫的一致性。
Example(示例)
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”的示例更具邏輯性,但是它們還會使更多的人感到困惑,尤其是依賴更常見,常規(guī)OK風格的教材的新手。
As ever, remember that the aim of these naming and layout rules is consistency and that aesthetics vary immensely.
與以往一樣,請記住,這些命名和布局規(guī)則的目的是保持一致性,它們會帶來代碼外觀的巨大變化。
This is a recommendation for?when you have no constraints or better ideas. This rule was added after many requests for guidance.
當您沒有約束或更好的選擇時,可以考慮這個個建議。此規(guī)則可以在許多準則之后適用。
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
新書介紹
《實戰(zhàn)Python設(shè)計模式》是作者最近出版的新書,拜托多多關(guān)注!

本書利用Python 的標準GUI 工具包tkinter,通過可執(zhí)行的示例對23 個設(shè)計模式逐個進行說明。這樣一方面可以使讀者了解真實的軟件開發(fā)工作中每個設(shè)計模式的運用場景和想要解決的問題;另一方面通過對這些問題的解決過程進行說明,讓讀者明白在編寫代碼時如何判斷使用設(shè)計模式的利弊,并合理運用設(shè)計模式。
對設(shè)計模式感興趣而且希望隨學隨用的讀者通過本書可以快速跨越從理解到運用的門檻;希望學習Python GUI 編程的讀者可以將本書中的示例作為設(shè)計和開發(fā)的參考;使用Python 語言進行圖像分析、數(shù)據(jù)處理工作的讀者可以直接以本書中的示例為基礎(chǔ),迅速構(gòu)建自己的系統(tǒng)架構(gòu)。
覺得本文有幫助?請分享給更多人。
關(guān)注微信公眾號【面向?qū)ο笏伎肌枯p松學習每一天!
面向?qū)ο箝_發(fā),面向?qū)ο笏伎迹?/span>
