您的位置:首页 > 编程语言 > C语言/C++

C++ Coding Style

2015-04-11 11:12 155 查看
This blog is to demonstrate the coding style that I use.

1) Variable Naming Rule

Usually a variable 's name consists of 3 parts, which are scope, prefix, and qualifier. 
The formulation is [Scope]_[Prefix][Qualifier].

Eg. m_nAge 
m means it's a member variable of a class or a structure. 
n means it's integer. 
Age demonstrates the usage of this variable.

1.1) Scope

Scope is the range in which a variable can be referenced. 

llocal variable
gglobal variable
mmember variable of a class or a structure
iinput variable
sstatic variable

1.2) Prefix

Prefix indicates the type of a variable.

IndexTypePrefix
1sbytesb
2bytebyte
3shorts
4ushortus
5intn
6uintun
7longl
8ulongul
9boolb
10charc
11floatf
12doubled
13decimaldm
14structstu
15enumenum
16objecto

1.3) Qualifier

Qualifier demonstrates the usage of a variable.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: