<?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: 7.3 &#8212; Passing arguments by reference</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/</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: Struct – Add One Day To The Date Using A Struct &#124; My Programming Notes</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-96856</link>
		<dc:creator>Struct – Add One Day To The Date Using A Struct &#124; My Programming Notes</dc:creator>
		<pubDate>Thu, 19 Jan 2012 08:02:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-96856</guid>
		<description>[...] KNOWLEDGE FOR THIS PROGRAM  Functions Passing a Value By Reference Integer Arrays Structures Constant Variables Boolean [...]</description>
		<content:encoded><![CDATA[<p>[...] KNOWLEDGE FOR THIS PROGRAM  Functions Passing a Value By Reference Integer Arrays Structures Constant Variables Boolean [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Passing arguments by address &#171; Learn C++ Programming</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-96846</link>
		<dc:creator>Passing arguments by address &#171; Learn C++ Programming</dc:creator>
		<pubDate>Mon, 16 Jan 2012 05:44:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-96846</guid>
		<description>[...] the lesson on passing arguments by reference, we briefly mentioned that references are typically implemented by the compiler as pointers. [...]</description>
		<content:encoded><![CDATA[<p>[...] the lesson on passing arguments by reference, we briefly mentioned that references are typically implemented by the compiler as pointers. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Struct &#8211; Add One Second To The Clock Using A Struct &#124; My Programming Notes</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-96800</link>
		<dc:creator>Struct &#8211; Add One Second To The Clock Using A Struct &#124; My Programming Notes</dc:creator>
		<pubDate>Mon, 09 Jan 2012 06:24:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-96800</guid>
		<description>[...] KNOWLEDGE FOR THIS PROGRAM  Functions Passing a Value By Reference Structures Constant Variables Boolean Expressions [...]</description>
		<content:encoded><![CDATA[<p>[...] KNOWLEDGE FOR THIS PROGRAM  Functions Passing a Value By Reference Structures Constant Variables Boolean Expressions [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: int first(int &#38; value) {} type function definition</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-96798</link>
		<dc:creator>int first(int &#38; value) {} type function definition</dc:creator>
		<pubDate>Mon, 09 Jan 2012 01:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-96798</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sujitbista</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-96508</link>
		<dc:creator>sujitbista</dc:creator>
		<pubDate>Tue, 29 Nov 2011 12:55:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-96508</guid>
		<description>The value assigned in dsin and dcos is returned to reference &amp;dsin and &amp;dcos which in turn passes the value to the calling fuction in the main program. So the code goes like this
 
 void main()
 {
 GetSincos(30.0,dSin,dCos);
cout&lt;&lt;&quot;The value of dSin is&quot;&lt;&lt;dSin&lt;&lt;endl;
cout&lt;&lt;&quot;The value of dcos is&quot;&lt;&lt;dCos;
 }</description>
		<content:encoded><![CDATA[<p>The value assigned in dsin and dcos is returned to reference &amp;dsin and &amp;dcos which in turn passes the value to the calling fuction in the main program. So the code goes like this</p>
<p> void main()<br />
 {<br />
 GetSincos(30.0,dSin,dCos);<br />
cout&lt;&lt;&quot;The value of dSin is&quot;&lt;&lt;dSin&lt;&lt;endl;<br />
cout&lt;&lt;&quot;The value of dcos is&quot;&lt;&lt;dCos;<br />
 }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xian</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-91533</link>
		<dc:creator>xian</dc:creator>
		<pubDate>Tue, 07 Sep 2010 00:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-91533</guid>
		<description>&quot;“Because references are typically implemented by C++ using pointers, and dereferencing a pointer is slower than accessing it directly, accessing values passed by reference is slower than accessing values passed by value.”

What is meant by accessing it directly? The value or the reference. If it should be reference I could use some further explanation… The way I understood the sentence is, that once the value is copied, it can be accessed easily.&quot;

You might translate this as &quot;... is slower than directly accessing the value that the pointer/reference refers to&quot;.

So:
&lt;pre&gt;
int i;
int n=10;
int directVals[n] = 0;
int pVals = &amp;directVals;

for (i=0; i&lt;n; i++) {
  directVals[i] = 1 // A - direct access is faster
  *pVals[i] =1       // B - accessing through de-referenced pointer is a little slower than A
}
 &lt;!--formatted--&gt;&lt;/pre&gt;
But, this speed to access data must be balanced against the time that it takes to copy data into a &quot;direct&quot; variable, as in pass-by-value.  For large n, the suggestion is that the copy time will outweight the speed-of-access time.  What&#039;s the break-even threshold?  Good question!</description>
		<content:encoded><![CDATA[<p>&#8220;“Because references are typically implemented by C++ using pointers, and dereferencing a pointer is slower than accessing it directly, accessing values passed by reference is slower than accessing values passed by value.”</p>
<p>What is meant by accessing it directly? The value or the reference. If it should be reference I could use some further explanation… The way I understood the sentence is, that once the value is copied, it can be accessed easily.&#8221;</p>
<p>You might translate this as &#8220;&#8230; is slower than directly accessing the value that the pointer/reference refers to&#8221;.</p>
<p>So:</p>
<pre>
int i;
int n=10;
int directVals[n] = 0;
int pVals = &#038;directVals;

for (i=0; i&lt;n; i++) {
  directVals[i] = 1 // A - direct access is faster
  *pVals[i] =1       // B - accessing through de-referenced pointer is a little slower than A
}
 <!--formatted--></pre>
<p>But, this speed to access data must be balanced against the time that it takes to copy data into a &quot;direct&quot; variable, as in pass-by-value.  For large n, the suggestion is that the copy time will outweight the speed-of-access time.  What&#39;s the break-even threshold?  Good question!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-90414</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Mon, 16 Aug 2010 21:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-90414</guid>
		<description>It tells the coder whether they need to worry about the function changing the value of the argument 

---&gt; It tells the coder whether he needs to worry about the function changing the value of the argument</description>
		<content:encoded><![CDATA[<p>It tells the coder whether they need to worry about the function changing the value of the argument </p>
<p>&#8212;&gt; It tells the coder whether he needs to worry about the function changing the value of the argument</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bla</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-90197</link>
		<dc:creator>bla</dc:creator>
		<pubDate>Fri, 13 Aug 2010 15:17:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-90197</guid>
		<description>&quot;Because references are typically implemented by C++ using pointers, and dereferencing a pointer is slower than accessing &lt;b&gt;it&lt;/b&gt; directly, accessing values passed by reference is slower than accessing values passed by value.&quot;

What is meant by accessing &lt;b&gt;it&lt;/b&gt; directly? The value or the reference. If it should be reference I could use some further explanation... The way I understood the sentence is, that once the value is copied, it can be accessed easily.

Btw I should mention that I like this site very much. Especially the quizzes, though there could be more of them ;-)</description>
		<content:encoded><![CDATA[<p>&#8220;Because references are typically implemented by C++ using pointers, and dereferencing a pointer is slower than accessing <b>it</b> directly, accessing values passed by reference is slower than accessing values passed by value.&#8221;</p>
<p>What is meant by accessing <b>it</b> directly? The value or the reference. If it should be reference I could use some further explanation&#8230; The way I understood the sentence is, that once the value is copied, it can be accessed easily.</p>
<p>Btw I should mention that I like this site very much. Especially the quizzes, though there could be more of them ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: C++ Tutorial and Online Ebook</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-87408</link>
		<dc:creator>C++ Tutorial and Online Ebook</dc:creator>
		<pubDate>Wed, 30 Jun 2010 00:58:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-87408</guid>
		<description>[...] 7.3 Passing arguments by reference [...]</description>
		<content:encoded><![CDATA[<p>[...] 7.3 Passing arguments by reference [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: variables in sperate functions</title>
		<link>http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/comment-page-1/#comment-84716</link>
		<dc:creator>variables in sperate functions</dc:creator>
		<pubDate>Sat, 15 May 2010 20:12:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/73-passing-arguments-by-reference/#comment-84716</guid>
		<description>[...]  [...]</description>
		<content:encoded><![CDATA[<p>[...]  [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

