代名符

来源:互联网 发布:知乎 现实 打怪 编辑:程序博客网 时间:2024/06/14 00:38

在 C++ 语言编程设计中常利用 #define 语句定义一类空的字符串代换技术, 被称为代名符定义.

代名符在程序中不起任何实际作用, 只能放在行首用来说明程序的设计者, 类的归属, 设计时间, 程序的分类或所处的总体位置等, 有助于读程序的信息. 如下所示:

另一个例子, 比如 MFC 程序的消息映射函数声明最前面的 afx_msg 也是代名符. afx_msg 定义在 afxwin.h 中, 如下:

摘自: 彭木根, 王淑凌. C++ STL程序员开发指南. 中国铁道出版社. 2003年4月: P6.

 

http://msdn.microsoft.com/en-us/library/k6tw900t.aspx
The afx_msg keyword suggests the effect of the C++ virtual keyword by distinguishing the handlers from other CWnd member functions. Note, however, that these functions are not actually virtual; they are instead implemented through message maps. Message maps depend solely on standard preprocessor macros, not on any extensions to the C++ language. The afx_msg keyword resolves to white space after preprocessing.

原创粉丝点击