<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>冒号论坛 &#187; Topic: duck typing可以取代继承多态吗？</title>
		<link>http://bbs.zhenghui.org/topic/duck-typing%e5%8f%af%e4%bb%a5%e5%8f%96%e4%bb%a3%e7%bb%a7%e6%89%bf%e5%a4%9a%e6%80%81%e5%90%97%ef%bc%9f</link>
		<description>冒号论坛 &raquo; Topic: duck typing可以取代继承多态吗？</description>
		<language>en-US</language>
		<pubDate>Wed, 08 Sep 2010 13:07:07 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://bbs.zhenghui.org/search.php</link>
		</textInput>
		<atom:link href="http://bbs.zhenghui.org/rss/topic/duck-typing%e5%8f%af%e4%bb%a5%e5%8f%96%e4%bb%a3%e7%bb%a7%e6%89%bf%e5%a4%9a%e6%80%81%e5%90%97%ef%bc%9f" rel="self" type="application/rss+xml" />

		<item>
			<title>Todd on "duck typing可以取代继承多态吗？"</title>
			<link>http://bbs.zhenghui.org/topic/duck-typing%e5%8f%af%e4%bb%a5%e5%8f%96%e4%bb%a3%e7%bb%a7%e6%89%bf%e5%a4%9a%e6%80%81%e5%90%97%ef%bc%9f#post-44</link>
			<pubDate>Thu, 11 Feb 2010 13:44:34 +0000</pubDate>
			<dc:creator>Todd</dc:creator>
			<guid isPermaLink="false">44@http://bbs.zhenghui.org/</guid>
			<description>&#60;p&#62;听说concept被C++0x移除了，不过在学习了解concept的过程中还是有不少收获。我起初认识concept是因为C++模版对类型参数的要求是隐式的，用户只能通过文档或者模版实现才能知晓，不够规范。所以希望能有一种机制能显式地声明模版的参数要求，这就是concept的作用之一。后来发现boost有concept check库，能部分模拟concetp的效果。
&#60;/p&#62;</description>
		</item>
		<item>
			<title>hui on "duck typing可以取代继承多态吗？"</title>
			<link>http://bbs.zhenghui.org/topic/duck-typing%e5%8f%af%e4%bb%a5%e5%8f%96%e4%bb%a3%e7%bb%a7%e6%89%bf%e5%a4%9a%e6%80%81%e5%90%97%ef%bc%9f#post-43</link>
			<pubDate>Thu, 11 Feb 2010 00:11:32 +0000</pubDate>
			<dc:creator>hui</dc:creator>
			<guid isPermaLink="false">43@http://bbs.zhenghui.org/</guid>
			<description>&#60;p&#62;在c++中，子类型多态（即你提到的继承多态）与参数多态的一个区别是绑定时间，导致前者运行效率不如后者，但不会如后者那样代码膨胀（code bloat）且难以调试。它们的另一个区别是类型的匹配方式：前者按名字（named conformance），后者按结构（structural conformance）的。前一种风格是优点是规范明确，缺点是灵活度低；后一种风格则正相反。C++0X中的concept是对参数多态的一种改进，在保持原有优点的情况下，还试图吸收子类型多态的规范更明确、类型检查更早（不用等到template instantiation time）、编译出错代码更理想等优点。然而不管怎样，concept的类型匹配还是隐式的（implicit）或自动的（automatic），这种灵活性还是有可能带来非预期的类型匹配问题。因此，子类型多态仍有其用武之地。&#60;/p&#62;
&#60;p&#62;P.S. concept尽管被广泛看好，遗憾的是，它仍于去年七月被标准委员会从C++0x中移除了（ &#60;a href=&#34;http://www.drdobbs.com/cpp/218600111&#34; rel=&#34;nofollow&#34;&#62;http://www.drdobbs.com/cpp/218600111&#60;/a&#62; ）
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Todd on "duck typing可以取代继承多态吗？"</title>
			<link>http://bbs.zhenghui.org/topic/duck-typing%e5%8f%af%e4%bb%a5%e5%8f%96%e4%bb%a3%e7%bb%a7%e6%89%bf%e5%a4%9a%e6%80%81%e5%90%97%ef%bc%9f#post-42</link>
			<pubDate>Wed, 10 Feb 2010 21:58:00 +0000</pubDate>
			<dc:creator>Todd</dc:creator>
			<guid isPermaLink="false">42@http://bbs.zhenghui.org/</guid>
			<description>&#60;p&#62;最近看到一位C++高手认为如果C++0x引入了concept(我认为本质上是带静态类型检查的duck typing)就可以不需要继承多态了。我对此持反对意见，我认为继承多态适合于top-down的设计方式；而concept适合于bottom-up的设计方式。二者在设计中都是需要。想听听郑老师的意见。&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.cppblog.com/longshanks/archive/2007/12/06/37915.html&#34; rel=&#34;nofollow&#34;&#62;http://www.cppblog.com/longshanks/archive/2007/12/06/37915.html&#60;/a&#62;
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
