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

📄 subject_26616.htm

📁 vc
💻 HTM
字号:
<p>
序号:26616 发表者:hl211 发表日期:2003-01-03 09:20:17
<br>主题:结构类型可以做数组的基类吗?
<br>内容:代码如下:<BR>IndexName* pIndexName;<BR>CBSR::CBSR(length)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nLength = length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pIndexName = new IndexName[nLength];<BR>}<BR><BR><BR>struct&nbsp;&nbsp;IndexName<BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp; index; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp; attrib; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CString&nbsp;&nbsp;LogicName;&nbsp;&nbsp;<BR>}
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:凯凯 回复日期:2003-01-03 10:26:29
<br>内容:ok
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:lin 回复日期:2003-01-03 10:27:48
<br>内容:当然可以<BR><BR>struct&nbsp;&nbsp;IndexName<BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp; index; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;&nbsp; attrib; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CString&nbsp;&nbsp;LogicName;&nbsp;&nbsp;<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; //分号不能少<BR><BR>IndexName* pIndexName;<BR>CBSR::CBSR(length)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pIndexName = NULL;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nLength = length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pIndexName = new IndexName[nLength];<BR>}<BR><BR>析构函数中&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete pIndexName;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //以防内存泄漏&nbsp;&nbsp;<BR><BR><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>
回复者:hl211 回复日期:2003-01-03 11:00:30
<br>内容:为什么在构造函数里要先:pIndexName=NULL; ?&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;析构函数最好是:delete []pIndexName;
<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 + -