<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: The Road to KDE Devland &#8211; step 2</title>
	<atom:link href="http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/</link>
	<description></description>
	<lastBuildDate>Sun, 22 Apr 2012 14:57:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: The Road to KDE Devland &#8211; step 4 &#171; Who Says Penguins Can&#39;t Fly?</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-303</link>
		<dc:creator><![CDATA[The Road to KDE Devland &#8211; step 4 &#171; Who Says Penguins Can&#39;t Fly?]]></dc:creator>
		<pubDate>Mon, 14 Sep 2009 21:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-303</guid>
		<description><![CDATA[[...] parent-child mechanism is out of scope for this article. I touched upon the subject in step 2, when I wrote about pointers in [...]]]></description>
		<content:encoded><![CDATA[<p>[...] parent-child mechanism is out of scope for this article. I touched upon the subject in step 2, when I wrote about pointers in [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-148</link>
		<dc:creator><![CDATA[Hans]]></dc:creator>
		<pubDate>Mon, 27 Jul 2009 09:09:51 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-148</guid>
		<description><![CDATA[@litb:
&quot;Only when the const appears at the type referred to, then you create a reference to const. Otherwise, your code is not valid:&quot;
Post updated, hope it&#039;s more clear now. Thanks for taking your time to explain. :)

@AhmedG.:
Thank you for your comment. It&#039;s always encouraging to see that people find the article useful.]]></description>
		<content:encoded><![CDATA[<p>@litb:<br />
&#8220;Only when the const appears at the type referred to, then you create a reference to const. Otherwise, your code is not valid:&#8221;<br />
Post updated, hope it&#8217;s more clear now. Thanks for taking your time to explain. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>@AhmedG.:<br />
Thank you for your comment. It&#8217;s always encouraging to see that people find the article useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Top Posts &#171; WordPress.com</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-146</link>
		<dc:creator><![CDATA[Top Posts &#171; WordPress.com]]></dc:creator>
		<pubDate>Mon, 27 Jul 2009 00:16:47 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-146</guid>
		<description><![CDATA[[...]  The Road to KDE Devland – step 2 Can anyone give me some pointers? After one week with Sams Teach Yourself C++ in 21 Days, it feels like I have the [...] [...]]]></description>
		<content:encoded><![CDATA[<p>[...]  The Road to KDE Devland – step 2 Can anyone give me some pointers? After one week with Sams Teach Yourself C++ in 21 Days, it feels like I have the [...] [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AhmedG.</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-145</link>
		<dc:creator><![CDATA[AhmedG.]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 18:40:15 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-145</guid>
		<description><![CDATA[Hey nice article! your explanation of pointers was well done. I wish it was around when I first learned pointers!]]></description>
		<content:encoded><![CDATA[<p>Hey nice article! your explanation of pointers was well done. I wish it was around when I first learned pointers!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: litb</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-144</link>
		<dc:creator><![CDATA[litb]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 18:40:06 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-144</guid>
		<description><![CDATA[Nice summary. Some comments follow. 

&quot;References are always “constant” (they can’t be reassigned), so const together with a reference will always make the object constant. However, this doesn’t apply to pointers:&quot;

This needs some elaboration, i think. Only when the const appears at the type referred to, then you create a reference to const. Otherwise, your code is not valid:

    int &amp;const a = ...; // not valid
    int const &amp;a = ...; // correct way

However, as you say, a reference conceptually is const. A const added to a reference type using a typedef is ignored (the same applies to template parameter: this is done to simplify generic programming):

    typedef int &amp;intref_type;
    intref_type const a = ...;
      // valid, equivalent to &quot;int &amp;a = ...;&quot;

Regarding whether to pass by const reference or by value, i follow the following rule:

&quot;If the function always takes a copy, then pass by value&quot;. 

For example, in the following case, pass by value:
  
    string toupper(string s) {
      /* some code that changes s directly */
      return s;
    }

Passing by reference would look like the following:

    string topper(string const &amp;s) {
        string tmp(s);
        /* some code that changes tmp */
        return tmp;
    }

In general, make the function prototype as transparent to the caller as possible, which opens a good range of optimization possibilities for the caller (compiler).]]></description>
		<content:encoded><![CDATA[<p>Nice summary. Some comments follow. </p>
<p>&#8220;References are always “constant” (they can’t be reassigned), so const together with a reference will always make the object constant. However, this doesn’t apply to pointers:&#8221;</p>
<p>This needs some elaboration, i think. Only when the const appears at the type referred to, then you create a reference to const. Otherwise, your code is not valid:</p>
<p>    int &amp;const a = &#8230;; // not valid<br />
    int const &amp;a = &#8230;; // correct way</p>
<p>However, as you say, a reference conceptually is const. A const added to a reference type using a typedef is ignored (the same applies to template parameter: this is done to simplify generic programming):</p>
<p>    typedef int &amp;intref_type;<br />
    intref_type const a = &#8230;;<br />
      // valid, equivalent to &#8220;int &amp;a = &#8230;;&#8221;</p>
<p>Regarding whether to pass by const reference or by value, i follow the following rule:</p>
<p>&#8220;If the function always takes a copy, then pass by value&#8221;. </p>
<p>For example, in the following case, pass by value:</p>
<p>    string toupper(string s) {<br />
      /* some code that changes s directly */<br />
      return s;<br />
    }</p>
<p>Passing by reference would look like the following:</p>
<p>    string topper(string const &amp;s) {<br />
        string tmp(s);<br />
        /* some code that changes tmp */<br />
        return tmp;<br />
    }</p>
<p>In general, make the function prototype as transparent to the caller as possible, which opens a good range of optimization possibilities for the caller (compiler).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Road to KDE and Qt Development &#171; cogito ergo vagus</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-143</link>
		<dc:creator><![CDATA[The Road to KDE and Qt Development &#171; cogito ergo vagus]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 17:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-143</guid>
		<description><![CDATA[[...] Road to KDE devland Step 0 Road to KDE devland Step 1 Road to KDE devland Step 2 [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Road to KDE devland Step 0 Road to KDE devland Step 1 Road to KDE devland Step 2 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Road to KDE and Qt Development &#124; veracity</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-141</link>
		<dc:creator><![CDATA[The Road to KDE and Qt Development &#124; veracity]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 16:18:54 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-141</guid>
		<description><![CDATA[[...] Road to KDE devland Step 0 Road to KDE devland Step 1 Road to KDE devland Step 2 [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Road to KDE devland Step 0 Road to KDE devland Step 1 Road to KDE devland Step 2 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-137</link>
		<dc:creator><![CDATA[Hans]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 14:13:41 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-137</guid>
		<description><![CDATA[@Diederik van der Boor:
Books usually have pretty good pictures, and I&#039;m too lazy to do them. :P

I think pictures are useful when introducing pointers, but I&#039;m not sure if a picture would help much here?]]></description>
		<content:encoded><![CDATA[<p>@Diederik van der Boor:<br />
Books usually have pretty good pictures, and I&#8217;m too lazy to do them. <img src='http://s2.wp.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I think pictures are useful when introducing pointers, but I&#8217;m not sure if a picture would help much here?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: atomopawn</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-136</link>
		<dc:creator><![CDATA[atomopawn]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 11:21:23 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-136</guid>
		<description><![CDATA[Another reason to use pointers over references is that pure C doesn&#039;t really support reference parameters.  So when you&#039;re doing (for instance) kernel programming, you have to go back to pointers and de-referencing.

I find it helpful to think of a reference as &quot;a different name for the same variable&quot; and to think of pointers as &quot;the memory address of a variable&quot;. 

I do think it&#039;s confusing that the &amp; and * symbols have two different meanings when used on the left and right side of an assignment.  But with practice, it becomes a little easier to remember.]]></description>
		<content:encoded><![CDATA[<p>Another reason to use pointers over references is that pure C doesn&#8217;t really support reference parameters.  So when you&#8217;re doing (for instance) kernel programming, you have to go back to pointers and de-referencing.</p>
<p>I find it helpful to think of a reference as &#8220;a different name for the same variable&#8221; and to think of pointers as &#8220;the memory address of a variable&#8221;. </p>
<p>I do think it&#8217;s confusing that the &amp; and * symbols have two different meanings when used on the left and right side of an assignment.  But with practice, it becomes a little easier to remember.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Diederik van der Boor</title>
		<link>http://hanschen.org/2009/07/25/the-road-to-kde-devland-step-2/#comment-135</link>
		<dc:creator><![CDATA[Diederik van der Boor]]></dc:creator>
		<pubDate>Sun, 26 Jul 2009 10:54:55 +0000</pubDate>
		<guid isPermaLink="false">http://hanswchen.wordpress.com/?p=366#comment-135</guid>
		<description><![CDATA[Nice post. :)

Something I got in my mind to write a long time ago. One thing I just tought of: would it be nice to draw some scheme of how an object with &quot;pointer on the stack&quot; looks like in comparison with an &quot;object allocated at the stack&quot; ? ;-)]]></description>
		<content:encoded><![CDATA[<p>Nice post. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Something I got in my mind to write a long time ago. One thing I just tought of: would it be nice to draw some scheme of how an object with &#8220;pointer on the stack&#8221; looks like in comparison with an &#8220;object allocated at the stack&#8221; ? <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

