<?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: 7.4 &#8212; Passing arguments by address</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/</link>
	<description></description>
	<pubDate>Fri, 29 Aug 2008 19:40:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-24937</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 26 Aug 2008 03:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-24937</guid>
		<description>I forgot to tell you to update the function prototype above main.  If it doesn't match the actual function, the compiler will be unhappy, as you're seeing.  Update the prototype to int *&#038; instead of int * and you'll be fine.</description>
		<content:encoded><![CDATA[<p>I forgot to tell you to update the function prototype above main.  If it doesn&#8217;t match the actual function, the compiler will be unhappy, as you&#8217;re seeing.  Update the prototype to int *&#038; instead of int * and you&#8217;ll be fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pieter</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-24290</link>
		<dc:creator>Pieter</dc:creator>
		<pubDate>Wed, 20 Aug 2008 18:22:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-24290</guid>
		<description>I can't get your last code (with the reference to a pointer) to work.
The linker gives the following error : 
1&#62;main.obj : error LNK2019: unresolved external symbol "void __cdecl SetToSix(int *)" (?SetToSix@@YAXPAH@Z) referenced in function _main
1&#62;D:\Users\Pieter\Documents\Visual Studio 2008\Projects\Test\Debug\Test.exe : fatal error LNK1120: 1 unresolved externals

However, I was thinking...
If you change pTempPtr = &#038;nSix; to *pTempPtr = nSix; (so dereference it and then assign the value of nSix) it works as it should, except that it doesn't change the address of pTempPtr, but rather the contents.</description>
		<content:encoded><![CDATA[<p>I can&#8217;t get your last code (with the reference to a pointer) to work.<br />
The linker gives the following error :<br />
1&gt;main.obj : error LNK2019: unresolved external symbol &#8220;void __cdecl SetToSix(int *)&#8221; (?SetToSix@@YAXPAH@Z) referenced in function _main<br />
1&gt;D:\Users\Pieter\Documents\Visual Studio 2008\Projects\Test\Debug\Test.exe : fatal error LNK1120: 1 unresolved externals</p>
<p>However, I was thinking&#8230;<br />
If you change pTempPtr = &nSix; to *pTempPtr = nSix; (so dereference it and then assign the value of nSix) it works as it should, except that it doesn&#8217;t change the address of pTempPtr, but rather the contents.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-20690</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Fri, 11 Jul 2008 02:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-20690</guid>
		<description>The perils of cut and paste on display.  Thanks for the note, it's fixed now.</description>
		<content:encoded><![CDATA[<p>The perils of cut and paste on display.  Thanks for the note, it&#8217;s fixed now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: el-mudo</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-20589</link>
		<dc:creator>el-mudo</dc:creator>
		<pubDate>Wed, 09 Jul 2008 15:34:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-20589</guid>
		<description>Hi Alex, it's me again
There is a small error in the last example in this page, you forgot to change the comments in the code, it's writen like that:

// This only changes pTempPtr, not pPtr!

but, in fact, for that example, pPtr has its memory address changed together with pTempPtr since it's a reference to it.</description>
		<content:encoded><![CDATA[<p>Hi Alex, it&#8217;s me again<br />
There is a small error in the last example in this page, you forgot to change the comments in the code, it&#8217;s writen like that:</p>
<p>// This only changes pTempPtr, not pPtr!</p>
<p>but, in fact, for that example, pPtr has its memory address changed together with pTempPtr since it&#8217;s a reference to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 7.3 &#8212; Passing arguments by reference</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-13488</link>
		<dc:creator>Learn C++ - &#187; 7.3 &#8212; Passing arguments by reference</dc:creator>
		<pubDate>Tue, 29 Apr 2008 04:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-13488</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; 7.2 &#8212; Passing arguments by value &#124; Home &#124; 7.4 &#8212; Passing arguments by address &#187;     Tuesday, July 24th, 2007 at 6:06 [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; 7.2 &#8212; Passing arguments by value | Home | 7.4 &#8212; Passing arguments by address &raquo;     Tuesday, July 24th, 2007 at 6:06 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-10027</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 20 Mar 2008 15:26:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-10027</guid>
		<description>You don't need to do an explicit dereference when using the array index operator ([]) because the array index operator does an implicit dereference.</description>
		<content:encoded><![CDATA[<p>You don&#8217;t need to do an explicit dereference when using the array index operator ([]) because the array index operator does an implicit dereference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-10001</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 20 Mar 2008 06:15:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-10001</guid>
		<description>1. In your first example function, PrintArray, don't you have to dereference the pnArray variable, like this??:

&lt;pre&gt;

void PrintArray(int *pnArray, int nLength)
{
    for (int iii=0; iii &lt; nLength; iii++)
        cout &lt;&lt; *pnArray[iii] &lt;&lt; endl;
}
&lt;/pre&gt;

2. Minor typo: "The next logical question is, â€œWhat if we want &lt;b&gt;to be able to be able to&lt;/b&gt; change the address"</description>
		<content:encoded><![CDATA[<p>1. In your first example function, PrintArray, don&#8217;t you have to dereference the pnArray variable, like this??:</p>
<pre>

void PrintArray(int *pnArray, int nLength)
{
    for (int iii=0; iii < nLength; iii++)
        cout << *pnArray[iii] << endl;
}
</pre>
<p>2. Minor typo: &#8220;The next logical question is, â€œWhat if we want <b>to be able to be able to</b> change the address&#8221;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-4719</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 20 Dec 2007 21:47:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-4719</guid>
		<description>Awesome, I get it.

I'd just like to say, that all made me realize that communicating C++'s logic is an artform.</description>
		<content:encoded><![CDATA[<p>Awesome, I get it.</p>
<p>I&#8217;d just like to say, that all made me realize that communicating C++&#8217;s logic is an artform.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-4703</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 20 Dec 2007 17:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-4703</guid>
		<description>I beefed up this lesson significantly because some of the stuff mentioned in the comments here is pretty important.</description>
		<content:encoded><![CDATA[<p>I beefed up this lesson significantly because some of the stuff mentioned in the comments here is pretty important.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://www.learncpp.com/cpp-tutorial/74-passing-arguments-by-address/#comment-4686</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Thu, 20 Dec 2007 08:30:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/uncategorized/74-passing-arguments-by-address/#comment-4686</guid>
		<description>Ok, the code below does act as your code does.  So, what's up with my: 
char *array = "strings"  code above? 

&lt;pre&gt;
void PrintArray(char *pnArray)   
{   
    pnArray[0] = 'c';
          
}  
 
int main()   
{   
  char anArray[2] = "a"; 
  cout &lt;&lt; anArray[0] &lt;&lt; endl;
  PrintArray(anArray);
  cout &lt;&lt; anArray[0] &lt;&lt; endl;
} 
Output:
a
c 
&lt;/pre&gt;

[ I think I answered this in my response above.  Let me know if it isn't clear. -Alex ]</description>
		<content:encoded><![CDATA[<p>Ok, the code below does act as your code does.  So, what&#8217;s up with my:<br />
char *array = &#8220;strings&#8221;  code above? </p>
<pre>
void PrintArray(char *pnArray)
{
    pnArray[0] = &#8216;c&#8217;;

}  

int main()
{
  char anArray[2] = &#8220;a&#8221;;
  cout < < anArray[0] << endl;
  PrintArray(anArray);
  cout << anArray[0] << endl;
}
Output:
a
c
</pre>
<p>[ I think I answered this in my response above.  Let me know if it isn't clear. -Alex ]</pre>
]]></content:encoded>
	</item>
</channel>
</rss>
