﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-Jinhao::天水涧-最新评论</title><link>http://jinhao.cnblogs.com/CommentsRSS.aspx</link><description>天水涧 一线之间</description><language>zh-cn</language><pubDate>Mon, 28 Jun 2004 21:12:24 GMT</pubDate><lastBuildDate>Mon, 28 Jun 2004 21:12:24 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: 混沌 IN C++::模板参数的奥秘</title><link>http://www.cnblogs.com/jinhao/archive/2008/05/02/14095.html#1179174</link><dc:creator>Ray L</dc:creator><author>Ray L</author><pubDate>Thu, 01 May 2008 22:16:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2008/05/02/14095.html#1179174</guid><description><![CDATA[我想你的看法有问题，类型定义本来就不具备外部连接。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">Ray L</a> 2008-05-02 06:16 <a href="http://www.cnblogs.com/jinhao/archive/2008/05/02/14095.html#1179174#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::模板参数的奥秘</title><link>http://www.cnblogs.com/jinhao/archive/2006/09/02/14095.html#492866</link><dc:creator>winlin</dc:creator><author>winlin</author><pubDate>Sat, 02 Sep 2006 02:28:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2006/09/02/14095.html#492866</guid><description><![CDATA[楼主,我写了一下,发现若是自定义类型作为模板的参数,要有两个条件:<br>1.参数为全局变量,不能是静态或者const的.<br>2.模板中要指针,引用不行.<br>代码如下:<br>1.首先是作为参数的自定义类的定义:<br>class Tplt <br>{<br>public:<br>	void Display();<br><br>};<br>2.然后是模板定义:<br>template&lt;class T, T *arg&gt;<br>class Container <br>{<br>public:<br>	void Do()<br>	{<br>		name.Display();<br>		arg-&gt;Display();<br>	}<br>private:<br>	T name;<br><br>};<br>其中,T*也可以写成Tplt*.<br>3.主函数:<br>Tplt arg;//必须是全局变量<br>void main()<br>{<br>	//WinLin::Instance()-&gt;Display();<br>	Container&lt;Tplt,&amp;arg&gt; theObj;<br>	theObj.Do();<br>}<br><br>所以我就那么认为了,要全局的自定义变量才可以作为模板参数;<br>敬请楼主和各位大虾指正/lh,偶的邮箱是winterServer@126.com<br>若确实如此,也请给小弟发封邮件,先感谢了.<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">winlin</a> 2006-09-02 10:28 <a href="http://www.cnblogs.com/jinhao/archive/2006/09/02/14095.html#492866#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::Template Metaprograms</title><link>http://www.cnblogs.com/jinhao/archive/2005/06/09/19372.html#171109</link><dc:creator>QQ394548</dc:creator><author>QQ394548</author><pubDate>Thu, 09 Jun 2005 07:14:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2005/06/09/19372.html#171109</guid><description><![CDATA[试了，好玩。开拓了视野。有心了。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">QQ394548</a> 2005-06-09 15:14 <a href="http://www.cnblogs.com/jinhao/archive/2005/06/09/19372.html#171109#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::Template Metaprograms</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19463</link><dc:creator>周星星</dc:creator><author>周星星</author><pubDate>Tue, 29 Jun 2004 04:58:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19463</guid><description><![CDATA[<FONT face=楷体_GB2312 size=2>您举的几个事例中条件都能在编译期间确定，因此说template替代if/if-else是不正确的，您这属于C++模板元编程(metaprogram)的范畴，模板元编程代替不了if-else，顶多能代替部分#if-#elif而已。</FONT><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">周星星</a> 2004-06-29 12:58 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19463#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::Template Metaprograms</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19402</link><dc:creator>mill2002</dc:creator><author>mill2002</author><pubDate>Tue, 29 Jun 2004 01:41:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19402</guid><description><![CDATA[dotNet的本意是要容合一切语言产生的产物的<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">mill2002</a> 2004-06-29 09:41 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19402#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::Template Metaprograms</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19397</link><dc:creator>unruledboy(灵感之源)</dc:creator><author>unruledboy(灵感之源)</author><pubDate>Tue, 29 Jun 2004 01:31:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19397</guid><description><![CDATA[的确没有，虽然我们专注于.NET技术，但仍然非常欢迎大家踊跃发表自己的技术心得，不限于.NET<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">unruledboy(灵感之源)</a> 2004-06-29 09:31 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19397#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::Template Metaprograms</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19376</link><dc:creator>吹雪</dc:creator><author>吹雪</author><pubDate>Mon, 28 Jun 2004 23:52:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19376</guid><description><![CDATA[这个帖子与.Net有什么联系吗？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">吹雪</a> 2004-06-29 07:52 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/29/19372.html#19376#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::模板参数的奥秘</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/09/14095.html#14329</link><dc:creator>周星星</dc:creator><author>周星星</author><pubDate>Wed, 09 Jun 2004 01:31:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/09/14095.html#14329</guid><description><![CDATA[谢谢两位！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">周星星</a> 2004-06-09 09:31 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/09/14095.html#14329#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::模板参数的奥秘</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/08/14095.html#14231</link><dc:creator>oldjacky</dc:creator><author>oldjacky</author><pubDate>Tue, 08 Jun 2004 11:42:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/08/14095.html#14231</guid><description><![CDATA[因为局部类不会被外部使用，所以会在编译函数的时候同时编译，但编译模版却是在这个过程之前，因此他不能够做为模版类型。&nbsp;<br><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">oldjacky</a> 2004-06-08 19:42 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/08/14095.html#14231#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 混沌 IN C++::动态资源管理陷阱</title><link>http://www.cnblogs.com/jinhao/archive/2004/06/08/13828.html#14228</link><dc:creator>完美废人</dc:creator><author>完美废人</author><pubDate>Tue, 08 Jun 2004 11:18:00 GMT</pubDate><guid>http://www.cnblogs.com/jinhao/archive/2004/06/08/13828.html#14228</guid><description><![CDATA[鸡丁兄：老师不是说过吗，new&nbsp;分配的内存不要用&nbsp;free&nbsp;释放，另外“自动存储区”和“堆”在&nbsp;C++&nbsp;编译器面前似乎是。。。一个东西？<br><br>void&nbsp;*&nbsp;operator&nbsp;new&nbsp;(size_t&nbsp;_sz)<br>{<br>&nbsp;&nbsp;return&nbsp;malloc(_sz);<br>}<br><br>void&nbsp;operator&nbsp;delete&nbsp;(void&nbsp;*&nbsp;p)<br>{<br>&nbsp;&nbsp;free(p);<br>}<br>偶觉得似乎。。。这个东西没什么不对。不能混用的理由是，很多时候&nbsp;delete&nbsp;的实现不是这么简单一个&nbsp;free&nbsp;搞定的。<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/jinhao/" target="_blank">完美废人</a> 2004-06-08 19:18 <a href="http://www.cnblogs.com/jinhao/archive/2004/06/08/13828.html#14228#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
