📄 subject_36369.htm
字号:
<p>
序号:36369 发表者:火骆驼 发表日期:2003-04-14 17:23:45
<br>主题:由谁能看懂这段代吗?
<br>内容:#define PCLASSINFO(cls, par) \<BR> public: \<BR> static const char * Class() \<BR> { return #cls; } \<BR> virtual const char * GetClass(unsigned ancestor = 0) const \<BR> { return ancestor > 0 ? par::GetClass(ancestor-1) : cls::Class(); } \<BR> virtual BOOL IsClass(const char * clsName) const \<BR> { return strcmp(clsName, cls::Class()) == 0; } \<BR> virtual BOOL IsDescendant(const char * clsName) const \<BR> { return strcmp(clsName, cls::Class()) == 0 || \<BR> par::IsDescendant(clsName); } \<BR> virtual Comparison CompareObjectMemoryDirect(const PObject & obj) const \<BR> { return (Comparison)memcmp(this, &obj, sizeof(cls)); } \<BR> PNEW_AND_DELETE_FUNCTIONS<BR><BR>几个问题:<BR>1、return #cls当中的#表示什么意思?<BR>2、这个define的作用是什么,定义的是一个类?<BR>3、
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:neilgan 回复日期:2003-04-14 22:24:55
<br>内容:1. '#' is a pre-processor operator, its function is to change a variable into a string. For example:<BR>PCLASSINFO(DerivedClass,ParentClass)<BR>then: #cls will be "DerivedClass"<BR><BR>2. This is a macro definition. When you add a line "PCLASSINFO(DeviredClass,ParentClass)" in your class definition,it defines several functions for the devired class.<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:salamander 回复日期:2003-04-15 19:36:04
<br>内容:你怎么知道 '#' is a pre-processor operator? 那么#include 中的#怎么解释?<BR>我没有见到别的地方再使用过#.如果你肯定,请把它的定义讲清楚.<BR><BR>btw:What does the word "devired" mean? I'm sure you can not find the word in any dictionary.Maybe There is a mistake.<BR><BR>waiting for your echo.....
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:jinz_di 回复日期:2003-04-15 22:19:09
<br>内容:"devired" 应为 "derived"之误.<BR>#见msdn
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:lvbin 回复日期:2003-04-16 11:13:59
<br>内容:The number-sign or “stringizing” operator (#) converts macro parameters (after expansion) to string constants. It is used only with macros that take arguments.
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -