<?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: 10.4 &#8212; Container classes</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/104-container-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/104-container-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: 16.2 &#8212; STL containers overview &#171; Learn C++</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-96001</link>
		<dc:creator>16.2 &#8212; STL containers overview &#171; Learn C++</dc:creator>
		<pubDate>Sun, 11 Sep 2011 23:42:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-96001</guid>
		<description>[...] 16.2 &#8212; STL containers overview  By Alex, on September 11th, 2011 By far the most commonly used functionality of the STL library are the STL container classes. If you need a quick refresher on container classes, check out lesson 10.4 &#8212; Container Classes. [...]</description>
		<content:encoded><![CDATA[<p>[...] 16.2 &#8212; STL containers overview  By Alex, on September 11th, 2011 By far the most commonly used functionality of the STL library are the STL container classes. If you need a quick refresher on container classes, check out lesson 10.4 &#8212; Container Classes. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: integral</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-95875</link>
		<dc:creator>integral</dc:creator>
		<pubDate>Thu, 18 Aug 2011 18:26:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-95875</guid>
		<description>In the Resize function, will it be a good idea to end it with the following line:
delete[] pnData;

If we dont include the above, could we run into a memory leak problem?</description>
		<content:encoded><![CDATA[<p>In the Resize function, will it be a good idea to end it with the following line:<br />
delete[] pnData;</p>
<p>If we dont include the above, could we run into a memory leak problem?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cooltoad</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-95165</link>
		<dc:creator>cooltoad</dc:creator>
		<pubDate>Tue, 08 Feb 2011 04:54:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-95165</guid>
		<description>Why did we need a Reallocate()? I don&#039;t see it being used anywhere.</description>
		<content:encoded><![CDATA[<p>Why did we need a Reallocate()? I don&#8217;t see it being used anywhere.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: D.M. Ryan</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-91704</link>
		<dc:creator>D.M. Ryan</dc:creator>
		<pubDate>Thu, 09 Sep 2010 08:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-91704</guid>
		<description>Error trapping, without aborting the function. If by some mistake a negative number is passed, the code will just empty the array. Example: if main() has a way to knock down a size variable nArraySize to -1 when the programmer really meant 0, the function will treat nArraySize as if it were zero. &lt;pre&gt;if (m_nLength &gt; 0)&lt;/pre&gt; allows the function to adjust for the programmer&#039;s intention with respect to emptying arrays.  

Plus, it&#039;s simpler to put in &lt;pre&gt;if (m_nLength &gt; 0)&lt;/pre&gt; than it would be to use &lt;pre&gt;if (m_nLength != 0)&lt;/pre&gt; and a separate error-checking line. Had &lt;pre&gt;if (m_nLength != 0)&lt;/pre&gt; been used, the function would have to guard against negative values with a line like &lt;pre&gt;assert(nIndex &gt;= 0);&lt;/pre&gt; Alex&#039;s choice collapses two lines into one, in a way that doesn&#039;t halt the program if a negative number gets passed. Since Resize doesn&#039;t declare an array, assert() isn&#039;t really needed.</description>
		<content:encoded><![CDATA[<p>Error trapping, without aborting the function. If by some mistake a negative number is passed, the code will just empty the array. Example: if main() has a way to knock down a size variable nArraySize to -1 when the programmer really meant 0, the function will treat nArraySize as if it were zero.
<pre>if (m_nLength &gt; 0)</pre>
<p> allows the function to adjust for the programmer&#8217;s intention with respect to emptying arrays.  </p>
<p>Plus, it&#8217;s simpler to put in
<pre>if (m_nLength &gt; 0)</pre>
<p> than it would be to use
<pre>if (m_nLength != 0)</pre>
<p> and a separate error-checking line. Had
<pre>if (m_nLength != 0)</pre>
<p> been used, the function would have to guard against negative values with a line like
<pre>assert(nIndex &gt;= 0);</pre>
<p> Alex&#8217;s choice collapses two lines into one, in a way that doesn&#8217;t halt the program if a negative number gets passed. Since Resize doesn&#8217;t declare an array, assert() isn&#8217;t really needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bla</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-90752</link>
		<dc:creator>bla</dc:creator>
		<pubDate>Mon, 23 Aug 2010 18:26:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-90752</guid>
		<description>In the Resize function, why do you put:
&lt;pre&gt; if (m_nLength &gt; 0) &lt;!--formatted--&gt;&lt;/pre&gt;
and not:
&lt;pre&gt; if (m_nLength != 0) &lt;/pre&gt;
?
This would, in my opinion, be more intuitively understandable (if m_nLength is &lt; 0 this shouldn&#039;t this cause an error?). Or did I misunderstand something here?</description>
		<content:encoded><![CDATA[<p>In the Resize function, why do you put:</p>
<pre> if (m_nLength &gt; 0) <!--formatted--></pre>
<p>and not:</p>
<pre> if (m_nLength != 0) </pre>
<p>?<br />
This would, in my opinion, be more intuitively understandable (if m_nLength is &lt; 0 this shouldn&#39;t this cause an error?). Or did I misunderstand something here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-89888</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Sun, 08 Aug 2010 20:49:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-89888</guid>
		<description>As an intermediate programmer using this site brushing up on my C++ I would definitely recommend at least adding a reference to the STL Container classes which would largely omit the need to write your own containers. If I didn&#039;t already know about them, seeing the need to write these myself would make me think twice using C++ for my coding needs.</description>
		<content:encoded><![CDATA[<p>As an intermediate programmer using this site brushing up on my C++ I would definitely recommend at least adding a reference to the STL Container classes which would largely omit the need to write your own containers. If I didn&#8217;t already know about them, seeing the need to write these myself would make me think twice using C++ for my coding needs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MarkG</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-48536</link>
		<dc:creator>MarkG</dc:creator>
		<pubDate>Mon, 02 Mar 2009 02:43:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-48536</guid>
		<description>Jacob,

I&#039;m just a beginner at c++ going through these examples, but I think what Alex has written is correct.  As there are (n+1) ways to insert an object &quot;next to&quot; (n) objects, it makes sense to call the InsertBefore function with the m_nLength parameter, even though the value you&#039;re inserting before doesn&#039;t exist in the array.  It worked well enough in the example of this code which I wrote and compiled.

Did I interpret your post correctly?  Maybe next time you could be a bit less cryptic :)

Mark</description>
		<content:encoded><![CDATA[<p>Jacob,</p>
<p>I&#8217;m just a beginner at c++ going through these examples, but I think what Alex has written is correct.  As there are (n+1) ways to insert an object &#8220;next to&#8221; (n) objects, it makes sense to call the InsertBefore function with the m_nLength parameter, even though the value you&#8217;re inserting before doesn&#8217;t exist in the array.  It worked well enough in the example of this code which I wrote and compiled.</p>
<p>Did I interpret your post correctly?  Maybe next time you could be a bit less cryptic :)</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-48410</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Sun, 01 Mar 2009 19:20:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-48410</guid>
		<description>Yes, I do have plans to cover relevant pieces of the standard library in future tutorials, including std::string and std::vector.</description>
		<content:encoded><![CDATA[<p>Yes, I do have plans to cover relevant pieces of the standard library in future tutorials, including std::string and std::vector.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacob Bundgaard</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-44536</link>
		<dc:creator>Jacob Bundgaard</dc:creator>
		<pubDate>Mon, 16 Feb 2009 21:57:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-44536</guid>
		<description>Just a little tip.
The InsertAtEnd function.
I hope you can figure it out from this:

assert(nIndex &gt;= 0 &amp;&amp; nIndex &lt; = m_nLength);
void InsertAtEnd(int nValue) { InsertBefore(nValue, &lt;b&gt;m_nLength&lt;/b&gt;); }</description>
		<content:encoded><![CDATA[<p>Just a little tip.<br />
The InsertAtEnd function.<br />
I hope you can figure it out from this:</p>
<p>assert(nIndex &gt;= 0 &amp;&amp; nIndex &lt; = m_nLength);<br />
void InsertAtEnd(int nValue) { InsertBefore(nValue, <b>m_nLength</b>); }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eugene Wee</title>
		<link>http://www.learncpp.com/cpp-tutorial/104-container-classes/comment-page-1/#comment-43397</link>
		<dc:creator>Eugene Wee</dc:creator>
		<pubDate>Fri, 13 Feb 2009 07:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/104-container-classes/#comment-43397</guid>
		<description>Have you considered teaching about std::vector and the other standard containers? For example, std::vector is far more efficient than your naive dynamic array example, but it is not suitable for a beginners&#039; tutorial to cover the sophistication that makes such efficiency possible, so it is best for beginners to at least get to know what should be used before trying to reinvent the wheel.</description>
		<content:encoded><![CDATA[<p>Have you considered teaching about std::vector and the other standard containers? For example, std::vector is far more efficient than your naive dynamic array example, but it is not suitable for a beginners&#8217; tutorial to cover the sophistication that makes such efficiency possible, so it is best for beginners to at least get to know what should be used before trying to reinvent the wheel.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

