<?xml version="1.0" encoding="UTF-8"?><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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 14.3 &#8212; Template classes</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/143-template-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/</link>
	<description></description>
	<lastBuildDate>Tue, 07 Feb 2012 12:30:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Pradeep</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-85050</link>
		<dc:creator>Pradeep</dc:creator>
		<pubDate>Thu, 20 May 2010 08:40:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-85050</guid>
		<description>Hi Alex,

The template version you provied if instatiated by a &#039;char&#039; it may cause problems becaue incounstructor you gave &quot;new T[length] but for char it needs &#039;new T[length+1]&#039; ( beacues of &quot;&quot;).

So changing the consturctor to the following may be appropriate.

&lt;pre&gt;
if(typeid(m_ptData) == typeid(char*))
       m_ptData = new T[nLength+1];
     else
       m_ptData = new T[nLength];
&lt;/pre&gt;

Also we need to include 
typeid determine sthe data type at runtime.

What do you say?</description>
		<content:encoded><![CDATA[<p>Hi Alex,</p>
<p>The template version you provied if instatiated by a &#8216;char&#8217; it may cause problems becaue incounstructor you gave &#8220;new T[length] but for char it needs &#8216;new T[length+1]&#8216; ( beacues of &#8220;&#8221;).</p>
<p>So changing the consturctor to the following may be appropriate.</p>
<pre>
if(typeid(m_ptData) == typeid(char*))
       m_ptData = new T[nLength+1];
     else
       m_ptData = new T[nLength];
</pre>
<p>Also we need to include<br />
typeid determine sthe data type at runtime.</p>
<p>What do you say?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobi</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-73674</link>
		<dc:creator>Tobi</dc:creator>
		<pubDate>Sat, 05 Dec 2009 12:07:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-73674</guid>
		<description>&lt;pre&gt;nCount----;)&lt;/pre&gt; should be &lt;pre&gt;nCount--)&lt;/pre&gt;?</description>
		<content:encoded><![CDATA[<pre>nCount----;)</pre>
<p> should be
<pre>nCount--)</pre>
<p>?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gilles</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-30461</link>
		<dc:creator>Gilles</dc:creator>
		<pubDate>Tue, 21 Oct 2008 19:54:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-30461</guid>
		<description>T Array::GetLength() shall return an int instead of a T

[ Fixed!  Thanks.  -Alex ]</description>
		<content:encoded><![CDATA[<p>T Array::GetLength() shall return an int instead of a T</p>
<p>[ Fixed!  Thanks.  -Alex ]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vinitha Krishnamurthy</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-29899</link>
		<dc:creator>Vinitha Krishnamurthy</dc:creator>
		<pubDate>Tue, 14 Oct 2008 02:38:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-29899</guid>
		<description>Alex,

I think, IntArray class uses composition and not aggregation. It is a value container class and not a reference container class.

Vinitha

[ I am constantly amazed by the attention to detail that my readers possess.  Very nice catch, and I appreciate you bringing it to my attention.  -Alex ]</description>
		<content:encoded><![CDATA[<p>Alex,</p>
<p>I think, IntArray class uses composition and not aggregation. It is a value container class and not a reference container class.</p>
<p>Vinitha</p>
<p>[ I am constantly amazed by the attention to detail that my readers possess.  Very nice catch, and I appreciate you bringing it to my attention.  -Alex ]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 14.4 &#8212; Expression parameters and template specialization</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-19391</link>
		<dc:creator>Learn C++ - &#187; 14.4 &#8212; Expression parameters and template specialization</dc:creator>
		<pubDate>Fri, 20 Jun 2008 03:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-19391</guid>
		<description>[...] 14.3 &#8212; Template classes  [...]</description>
		<content:encoded><![CDATA[<p>[...] 14.3 &#8212; Template classes  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 14.2 &#8212; Function template instances</title>
		<link>http://www.learncpp.com/cpp-tutorial/143-template-classes/comment-page-1/#comment-19165</link>
		<dc:creator>Learn C++ - &#187; 14.2 &#8212; Function template instances</dc:creator>
		<pubDate>Tue, 17 Jun 2008 04:05:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/?p=206#comment-19165</guid>
		<description>[...] 14.3 &#8212; Template classes  [...]</description>
		<content:encoded><![CDATA[<p>[...] 14.3 &#8212; Template classes  [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

