<?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"
	>
<channel>
	<title>Comments on: 9.2 &#8212; Overloading the arithmetic operators</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/</link>
	<description></description>
	<pubDate>Sat, 17 May 2008 09:56:32 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Learn C++ - &#187; 9.1 &#8212; Introduction to operator overloading</title>
		<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-14401</link>
		<dc:creator>Learn C++ - &#187; 9.1 &#8212; Introduction to operator overloading</dc:creator>
		<pubDate>Mon, 05 May 2008 02:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-14401</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; 8.13 &#8212; Friend functions and classes &#124; Home &#124; 9.2 &#8212; Overloading the arithmetic operators &#187;     Monday, September 24th, 2007 at 2:23 [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; 8.13 &#8212; Friend functions and classes | Home | 9.2 &#8212; Overloading the arithmetic operators &raquo;     Monday, September 24th, 2007 at 2:23 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-10921</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 04 Apr 2008 15:53:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-10921</guid>
		<description>Thanks for the edits.  As for point B, that's actually an interesting concern.  If possible, it's always a good idea to think about how the user might misuse a class -- and if there's a reasonable way to handle it, then do so.  In this case, your suggestion is perfect -- if the user passes in the min and max in the wrong order to the constructor, we can detect that and flip them.</description>
		<content:encoded><![CDATA[<p>Thanks for the edits.  As for point B, that&#8217;s actually an interesting concern.  If possible, it&#8217;s always a good idea to think about how the user might misuse a class &#8212; and if there&#8217;s a reasonable way to handle it, then do so.  In this case, your suggestion is perfect &#8212; if the user passes in the min and max in the wrong order to the constructor, we can detect that and flip them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-10916</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Fri, 04 Apr 2008 13:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-10916</guid>
		<description>Hello Alex -

A. Two typos:

   1. "When the operator does not modify &lt;b&gt;its&lt;/b&gt; operands"

   2. "Finally, implementation: to add &lt;b&gt;two&lt;/b&gt; Cents objects together"

B. If instead of:

&lt;pre&gt;MinMax cM2(8, 11);&lt;/pre&gt;

we had:

&lt;pre&gt;MinMax cM2(25, 2);&lt;/pre&gt;

that would break the logic of the code (it would still return 3,16 instead of 2,25). How would you handle it? Like this maybe?:

&lt;pre&gt;
public: 
     MinMax(int nMin, int nMax)  
     {  
         m_nMin = nMin &lt; nMax ? nMin : nMax;
         m_nMax = nMax &gt; nMin ? nMax : nMin; 
     } 
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Hello Alex -</p>
<p>A. Two typos:</p>
<p>   1. &#8220;When the operator does not modify <b>its</b> operands&#8221;</p>
<p>   2. &#8220;Finally, implementation: to add <b>two</b> Cents objects together&#8221;</p>
<p>B. If instead of:</p>
<pre>MinMax cM2(8, 11);</pre>
<p>we had:</p>
<pre>MinMax cM2(25, 2);</pre>
<p>that would break the logic of the code (it would still return 3,16 instead of 2,25). How would you handle it? Like this maybe?:</p>
<pre>
public:
     MinMax(int nMin, int nMax)
     {
         m_nMin = nMin < nMax ? nMin : nMax;
         m_nMax = nMax > nMin ? nMax : nMin;
     }
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 9.6 -- Overloading operators using member functions</title>
		<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-1880</link>
		<dc:creator>Learn C++ - &#187; 9.6 -- Overloading operators using member functions</dc:creator>
		<pubDate>Thu, 11 Oct 2007 18:22:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-1880</guid>
		<description>[...] &#8212; Overloading operators using member functions   By Alex     In the lesson on overloading the arithmetic operators, you learned that when the operator does not modify it&#8217;s operands, it&#8217;s best to [...]</description>
		<content:encoded><![CDATA[<p>[...] &#8212; Overloading operators using member functions   By Alex     In the lesson on overloading the arithmetic operators, you learned that when the operator does not modify it&#8217;s operands, it&#8217;s best to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 9.4 -- Overloading the comparison operators</title>
		<link>http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-1700</link>
		<dc:creator>Learn C++ - &#187; 9.4 -- Overloading the comparison operators</dc:creator>
		<pubDate>Fri, 05 Oct 2007 01:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/92-overloading-the-arithmetic-operators/#comment-1700</guid>
		<description>[...] 9.2 &#8212; Overloading the arithmetic operators Category Indexes [...]</description>
		<content:encoded><![CDATA[<p>[...] 9.2 &#8212; Overloading the arithmetic operators Category Indexes [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 1.064 seconds -->
