<?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: 9.7 &#8212; Overloading the increment and decrement operators</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/</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: Dr. HaXX</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-95148</link>
		<dc:creator>Dr. HaXX</dc:creator>
		<pubDate>Wed, 02 Feb 2011 15:08:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-95148</guid>
		<description>Second example, line 61: increment should be decrement ;)</description>
		<content:encoded><![CDATA[<p>Second example, line 61: increment should be decrement ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mslade</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-95000</link>
		<dc:creator>mslade</dc:creator>
		<pubDate>Sat, 04 Dec 2010 02:58:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-95000</guid>
		<description>I was about to note the same error, and my name is also Mark... Coincidence.... or fate?</description>
		<content:encoded><![CDATA[<p>I was about to note the same error, and my name is also Mark&#8230; Coincidence&#8230;. or fate?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-88468</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 15 Jul 2010 12:09:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-88468</guid>
		<description>First thanks very much for these tutorials. they&#039;re cracking.

Just a little proofing moment - in the 2nd to last paragraph &quot;Note that this means the return value of the overloaded operator much be a non-reference&quot; should that be a &quot;must&quot; rather than a &quot;much&quot;?

Cheers

Mark</description>
		<content:encoded><![CDATA[<p>First thanks very much for these tutorials. they&#8217;re cracking.</p>
<p>Just a little proofing moment &#8211; in the 2nd to last paragraph &#8220;Note that this means the return value of the overloaded operator much be a non-reference&#8221; should that be a &#8220;must&#8221; rather than a &#8220;much&#8221;?</p>
<p>Cheers</p>
<p>Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Soia</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-66269</link>
		<dc:creator>Soia</dc:creator>
		<pubDate>Fri, 14 Aug 2009 18:54:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-66269</guid>
		<description>Turns out it wasn&#039;t the case at all, what happened was that my operator&lt;&lt; recieved the object parameter as not const. It seems that when you pass the object parameter to the operator&lt;&lt; as const, as it should always be, it solves my problem.</description>
		<content:encoded><![CDATA[<p>Turns out it wasn&#8217;t the case at all, what happened was that my operator&lt;&lt; recieved the object parameter as not const. It seems that when you pass the object parameter to the operator&lt;&lt; as const, as it should always be, it solves my problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Soia</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-66173</link>
		<dc:creator>Soia</dc:creator>
		<pubDate>Thu, 13 Aug 2009 13:26:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-66173</guid>
		<description>I have a question.

The way the postfix is implemented... you can&#039;t do something like this:

&lt;pre&gt; cout &lt;&lt; cDigit++ &lt;&lt; endl; &lt;/pre&gt;

And I think it&#039;s because the postfix returns a value, and not a reference, whereas the operator&lt;&lt; receives a reference as parameter, and not a value.

Any thoughts on this? I wanna be able to print a postfix.

Thanks in advance.</description>
		<content:encoded><![CDATA[<p>I have a question.</p>
<p>The way the postfix is implemented&#8230; you can&#8217;t do something like this:</p>
<pre> cout &lt;&lt; cDigit++ &lt;&lt; endl; </pre>
<p>And I think it&#8217;s because the postfix returns a value, and not a reference, whereas the operator&lt;&lt; receives a reference as parameter, and not a value.</p>
<p>Any thoughts on this? I wanna be able to print a postfix.</p>
<p>Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rom</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-62856</link>
		<dc:creator>Rom</dc:creator>
		<pubDate>Mon, 22 Jun 2009 12:13:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-62856</guid>
		<description>&lt;code&gt;m_nDigit = (m_nDigit + 1) % 10;

&lt;/code&gt;

can be even shorter:

&lt;code&gt;m_nDigit = ++m_nDigit % 10;

&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><code>m_nDigit = (m_nDigit + 1) % 10;</p>
<p></code></p>
<p>can be even shorter:</p>
<p><code>m_nDigit = ++m_nDigit % 10;</p>
<p></code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Israel</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-61183</link>
		<dc:creator>Israel</dc:creator>
		<pubDate>Wed, 20 May 2009 09:35:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-61183</guid>
		<description>You can replace this:
&lt;pre&gt;
    // If our number is already at 9, wrap around to 0
    if (m_nDigit == 9)
        m_nDigit = 0;
    // otherwise just increment to next number
    else
        ++m_nDigit;
&lt;/pre&gt;
with:
&lt;pre&gt;
        m_nDigit = (m_nDigit + 1) % 10;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>You can replace this:</p>
<pre>
    // If our number is already at 9, wrap around to 0
    if (m_nDigit == 9)
        m_nDigit = 0;
    // otherwise just increment to next number
    else
        ++m_nDigit;
</pre>
<p>with:</p>
<pre>
        m_nDigit = (m_nDigit + 1) % 10;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-42005</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 06 Feb 2009 08:13:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-42005</guid>
		<description>No, this always points to the instance of the class itself, so in this case this points to the Digit object that contains m_nDigit.

That line simply invokes the prefix decrement operator on the same object that the postfix decrement operator was called on.</description>
		<content:encoded><![CDATA[<p>No, this always points to the instance of the class itself, so in this case this points to the Digit object that contains m_nDigit.</p>
<p>That line simply invokes the prefix decrement operator on the same object that the postfix decrement operator was called on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrian</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-39608</link>
		<dc:creator>Andrian</dc:creator>
		<pubDate>Wed, 28 Jan 2009 03:53:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-39608</guid>
		<description>&lt;pre&gt;
# Digit Digit::operator--(int)  
# {  
#     // Create a temporary variable with our current digit  
#     Digit cResult(m_nDigit);  
#   
#     // Use prefix operator to increment this digit  
#     --(*this);             // apply operator  
#   
#     // return temporary result  
#     return cResult;       // return saved state  
# }  
&lt;/pre&gt;
The &quot;*this&quot; in this function refers to &#039;m_nDigit&#039;?</description>
		<content:encoded><![CDATA[<pre>
# Digit Digit::operator--(int)
# {
#     // Create a temporary variable with our current digit
#     Digit cResult(m_nDigit);
#
#     // Use prefix operator to increment this digit
#     --(*this);             // apply operator
#
#     // return temporary result
#     return cResult;       // return saved state
# }
</pre>
<p>The &#8220;*this&#8221; in this function refers to &#8216;m_nDigit&#8217;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/97-overloading-the-increment-and-decrement-operators/comment-page-1/#comment-32310</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 18 Nov 2008 03:47:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/97-overloading-the-and-operators/#comment-32310</guid>
		<description>There&#039;s no reason at all -- In fact, it&#039;s pretty much useless to do.  I&#039;ve updated the example to remove the extraneous const values.</description>
		<content:encoded><![CDATA[<p>There&#8217;s no reason at all &#8212; In fact, it&#8217;s pretty much useless to do.  I&#8217;ve updated the example to remove the extraneous const values.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

