1.匈牙利命名规则 变动 前缀 类型 a Array bl Boolean //b Boolean b Byte //by Byte c Char //有符号型字符 cb Char Byte //无符号型字符(没多大用处) cr ColorRef //颜色参考值 cx,cy Length of x,y (ShortInt) //坐标差(长度) dw Double Word fn Function h Handle i Integer m_ Member of a class n Short Integer np Near Pointer p Pointer lp Long Pointer ×(str) s String sz String with Zero End //以字符'/0'结尾的字符串 tm Text //文本内容 w Word x,y Coordinate //坐标 2.系统命名约定 2.1 VC中变量命名时的前缀约定 Array a... //例:CStringArray saText BOOL b... UINT n... int i... short n... long l... WORD w... DWORD dw... float f... char c... char* psz... TCHAR* psz... LPCTSTR lpsz... CString str... COLORREF cr... LPLOGPALETTE lp... (包括LP开头的类型都是这样) POINT pt... CPoint pt... HANDLE h... HGLOBAL h... (包括H开头的类型都是这样) 说明: 1.如果是指向上述类型的指针,就在上面规范前加 "p" ; 2.如果是指向上述类型的双重指针,就在上面规范前加 "pp" ; 3.如果是类成员变量,则在上面规范前加 "m_"; 4.全局变量,则在上面规范前加 "g_"; 5.在类型前加了"const",命名约定不变; //最好在其中加个c,比如psz --> pcsz. 2.2 VC中变量命名时的后缀约定 1.MFC类 CWnd* p...Wnd 省去的地方一般为该类的用途 (如果是某一个类的成员,则还应该在前加 "m_")又如:CView* p...View 2.3 局部变量应尽量易懂简洁,使用常见的变量,如Num,nCount,i,j,k,n,len,pos, offset,nReadNum,index,nRet,ret, string,filename临时变量,如ltmp,ftmp,tmpStr,tempStr 。。。 2.5 禁止使用汉语拼音来命名; 2.6在代码中尽量不用具体的大小数值,定义成宏,便于以后维护,如: #define MAX_DOWNLOADNUM 20 2.7 VC中一些控件的缩写: ComboBox cmb Edit edt Dialog dlg ListBox lst Picture pic Animate ani
2.4 函数命名也应该见名知意。如CalcAllDataStyle(),ReadDocDataFromTime(),GetIndexInfo()
常见的函数Init_, Open_, Create_, Get_, Set_, Read_, Load_, Write_, Start_, Stop_, Check_, Test_, Fill_, Process_, Sort_, Do_, Select_, Is_, Exist_,_Ex…
struct DownInfo m_DownInfo[MAX_DOWNLOADNUM];
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>