匈牙利命名法

来源:互联网 发布:淘宝知己知彼怎么样 编辑:程序博客网 时间:2024/06/07 04:59

http://hi.baidu.com/chaosaco/item/68573af2e7dd1610d7ff8ce6  


 a         Array                                              数组 


   b         BOOL (int)                                     布尔(整数) 

   by       Unsigned Char (Byte)                    无符号字符(字节) 

   c         Char                                              字符(字节) 

   cb       Count of bytes                              字节数 

   cr        Color reference value                   颜色(参考)值 

   cx       Count of x (Short)                          x的集合(短整数) 

   dw      DWORD(unsigned long)                双字(无符号长整数) 

   f          Flags (usually multiple bit values)    标志(一般是有多位的数值) 

   fn        Function                                        函数 

   g_       global                                            全局的 

   h         Handle                                          句柄 

   i          Integer                                          整数 

   l          Long                                             长整数 

   lp        Long pointer                                 长指针 

   m_      Data member of a class                一个类的数据成员 

   n        Short int                                        短整数 

   p        Pointer                                          指针 

   s         String                                           字符串 

   sz        Zero terminated String                以0结尾的字符串 

   tm      Text metric                                   文本规则 

   u         Unsigned int                                无符号整数 

   ul        Unsigned long (ULONG)             无符号长整数 

   w        WORD (unsigned short)              无符号短整数 

   x,y      x, y coordinates (short)               坐标值/短整数 

   v         void                                            空 



        有关项目的全局变量用g_开始,类成员变量用m_,局部变量若函数较大则可考虑用l_用以显示说明其是局部变量。 



前缀        类型                  例子 

g_          全局变量            g_Servers 

C            类或者结构体 CDocument,CPrintInfo 

m_         成员变量            m_pDoc,m_nCustomers 



VC常用前缀列表: 

前缀    类型                 描述                                                                                            例子 

ch       char                 8位字符                                                                                      chGrade 

ch       TCHAR            16位UNICODE类型字符                                                              chName 

b         BOOL              布尔变量                                                                                  bEnabled 

n         int                    整型(其大小由操作系统决定)                                                 nLength 

n         UINT                无符号整型(其大小由操作系统决定)                                       nLength 

w        WORD            16位无符号整型                                                                          wPos 

l          LONG           32位有符号整型                                                                          lOffset 

dw      DWORD          32位无符号整型                                                                         dwRange 

p        *                       Ambient memory model pointer 内存模块指针,指针变量         pDoc 

lp        FAR*               长指针                                                                                     lpDoc 

lpsz     LPSTR           32位字符串指针                                                                         lpszName 

lpsz     LPCSTR       2位常量字符串指针                                                                      lpszName 

lpsz     LPCTSTR    32位UNICODE类型常量指针                                                        lpszName 

h        handle           Windows对象句柄                                                                       hWnd 

lpfn     (*fn)()            回调函数指针 Callback Far pointer to CALLBACK function         lpfnAbort
0 0