⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_36369.htm

📁 vc
💻 HTM
字号:
<p>
序号:36369 发表者:火骆驼 发表日期:2003-04-14 17:23:45
<br>主题:由谁能看懂这段代吗?
<br>内容:#define PCLASSINFO(cls, par) \<BR>&nbsp;&nbsp;public: \<BR>&nbsp;&nbsp;&nbsp;&nbsp;static const char * Class() \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return #cls; } \<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual const char * GetClass(unsigned ancestor = 0) const \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return ancestor &gt; 0 ? par::GetClass(ancestor-1) : cls::Class(); } \<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL IsClass(const char * clsName) const \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return strcmp(clsName, cls::Class()) == 0; } \<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual BOOL IsDescendant(const char * clsName) const \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return strcmp(clsName, cls::Class()) == 0 || \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; par::IsDescendant(clsName); } \<BR>&nbsp;&nbsp;&nbsp;&nbsp;virtual Comparison CompareObjectMemoryDirect(const PObject &amp; obj) const \<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return (Comparison)memcmp(this, &amp;obj, sizeof(cls)); } \<BR>&nbsp;&nbsp;&nbsp;&nbsp;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 + -