<?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.8 &#8212; Function Pointers</title>
	<atom:link href="http://www.learncpp.com/cpp-tutorial/78-function-pointers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/</link>
	<description></description>
	<lastBuildDate>Tue, 09 Mar 2010 02:02:41 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Atul</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-79728</link>
		<dc:creator>Atul</dc:creator>
		<pubDate>Fri, 05 Mar 2010 01:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-79728</guid>
		<description>awsome post..i love it.. :)</description>
		<content:encoded><![CDATA[<p>awsome post..i love it.. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ravi</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-72544</link>
		<dc:creator>Ravi</dc:creator>
		<pubDate>Thu, 19 Nov 2009 11:47:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-72544</guid>
		<description>Hi,

Nice way of explaining the Function pointers.

I tried to compile the code given up and  I am still getting this error

error: prototype for ‘void Kas::secondfunction(int (Kas::*)(int), int)’ does not match any in class ‘Kas’
error: candidate is: void Kas::secondfunction(int (*)(int), int)</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Nice way of explaining the Function pointers.</p>
<p>I tried to compile the code given up and  I am still getting this error</p>
<p>error: prototype for ‘void Kas::secondfunction(int (Kas::*)(int), int)’ does not match any in class ‘Kas’<br />
error: candidate is: void Kas::secondfunction(int (*)(int), int)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hasan Yavuz Özderya</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-69942</link>
		<dc:creator>Hasan Yavuz Özderya</dc:creator>
		<pubDate>Thu, 08 Oct 2009 09:06:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-69942</guid>
		<description>Solved !

&lt;pre&gt;
void Kas::secondfunction ( int (Kas::*ptofunction)(int),int t){
	 (this-&gt;*ptofunction)(t);
};

void Kas::thirdfunction (){
	 secondfunction(&amp;Kas::firstfunction,3);
};
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Solved !</p>
<pre>
void Kas::secondfunction ( int (Kas::*ptofunction)(int),int t){
	 (this-&gt;*ptofunction)(t);
};

void Kas::thirdfunction (){
	 secondfunction(&amp;Kas::firstfunction,3);
};
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hasan Yavuz Özderya</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-69795</link>
		<dc:creator>Hasan Yavuz Özderya</dc:creator>
		<pubDate>Mon, 05 Oct 2009 06:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-69795</guid>
		<description>I have a problem:

I write a class.

There is a function, member of this class.

There is another function, member of this class, takes a &quot;function pointer&quot; as parameter.

Inside this class there is also a third function and it calls the second function with a function pointer to first function as parameter.

Here is the code:

&lt;pre&gt;
#include &lt;iostream&gt;
using namespace std;

class Kas {
	  
	 public:		 
	  int ada;
	  
	  int firstfunction (int);
	  
	  void secondfunction (int (*ptofunction)(int), int t);
	  
	  
	  
	  void thirdfunction ();
	  	  
};

void Kas::secondfunction ( int (*ptofunction)(int),int t){
	 (*ptofunction)(t);	 
};

int Kas::firstfunction (int s) {
	 return ada+s;
};

void Kas::thirdfunction (){
	 secondfunction(firstfunction,3);	//The problem is here!! 
};

int main () {
    
    Kas den;
    den.thirdfunction();
    cout&lt;&lt;den.ada&lt;&lt;&quot;\n&quot;;
    
    system(&quot;PAUSE&quot;);
    return 0;
    
}

&lt;/pre&gt;

how can I call the second function?</description>
		<content:encoded><![CDATA[<p>I have a problem:</p>
<p>I write a class.</p>
<p>There is a function, member of this class.</p>
<p>There is another function, member of this class, takes a &#8220;function pointer&#8221; as parameter.</p>
<p>Inside this class there is also a third function and it calls the second function with a function pointer to first function as parameter.</p>
<p>Here is the code:</p>
<pre>
#include &lt;iostream&gt;
using namespace std;

class Kas {

	 public:
	  int ada;

	  int firstfunction (int);

	  void secondfunction (int (*ptofunction)(int), int t);

	  void thirdfunction ();

};

void Kas::secondfunction ( int (*ptofunction)(int),int t){
	 (*ptofunction)(t);
};

int Kas::firstfunction (int s) {
	 return ada+s;
};

void Kas::thirdfunction (){
	 secondfunction(firstfunction,3);	//The problem is here!!
};

int main () {

    Kas den;
    den.thirdfunction();
    cout&lt;&lt;den.ada&lt;&lt;&quot;\n&quot;;

    system(&quot;PAUSE&quot;);
    return 0;

}
</pre>
<p>how can I call the second function?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gaurav</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-65791</link>
		<dc:creator>gaurav</dc:creator>
		<pubDate>Fri, 07 Aug 2009 06:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-65791</guid>
		<description>Its strange you didn&#039;t cover pointers to member functions...anyways great tutorial overall.</description>
		<content:encoded><![CDATA[<p>Its strange you didn&#8217;t cover pointers to member functions&#8230;anyways great tutorial overall.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dusty</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-64653</link>
		<dc:creator>Dusty</dc:creator>
		<pubDate>Mon, 20 Jul 2009 15:38:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-64653</guid>
		<description>ROCKIN!!! Been trying to get my head around function pointers for ages!!! 

Now I get it!!! 

Probably forget again tomorrow, but at least I can come here and look it up again!

THANK YOU!!!!</description>
		<content:encoded><![CDATA[<p>ROCKIN!!! Been trying to get my head around function pointers for ages!!! </p>
<p>Now I get it!!! </p>
<p>Probably forget again tomorrow, but at least I can come here and look it up again!</p>
<p>THANK YOU!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-63817</link>
		<dc:creator>Ryan</dc:creator>
		<pubDate>Mon, 06 Jul 2009 14:57:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-63817</guid>
		<description>You left two things out of your full example.

1. You forgot to include iostream needed to define the &#039;cout&#039;

2.&lt;pre&gt;
void PrintArray(int *pArray, int nSize)
{
    for (int iii=0; iii &lt; nSize; iii++)
        cout &lt;&lt; pArray[iii] &lt;&lt; &quot; &quot;;
    cout &lt;&lt; endl;
}
&lt;/pre&gt;

You forgot to add &#039;using namespace std;&#039; thus cout doesn&#039;t work here.</description>
		<content:encoded><![CDATA[<p>You left two things out of your full example.</p>
<p>1. You forgot to include iostream needed to define the &#8216;cout&#8217;</p>
<p>2.
<pre>
void PrintArray(int *pArray, int nSize)
{
    for (int iii=0; iii &lt; nSize; iii++)
        cout &lt;&lt; pArray[iii] &lt;&lt; &quot; &quot;;
    cout &lt;&lt; endl;
}
</pre>
<p>You forgot to add &#8216;using namespace std;&#8217; thus cout doesn&#8217;t work here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fernando</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-62145</link>
		<dc:creator>fernando</dc:creator>
		<pubDate>Tue, 09 Jun 2009 09:34:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-62145</guid>
		<description>Should the function call not return some value ?
&lt;pre&gt;
1.int foo(int nX)
2.{
3.}
4. 
5.int (*pFoo)(int) = foo; // assign pFoo to foo()
6. 
7.(*pFoo)(nValue); // call function foo(nValue) through pFoo.

The second way is via implicit dereference:
view source
print?
1.int foo(int nX)
2.{
3.}
4. 
5.int (*pFoo)(int) = foo; // assign pFoo to foo()
6. 
7.pFoo(nValue); // call function foo(nValue) through pFoo.
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Should the function call not return some value ?</p>
<pre>
1.int foo(int nX)
2.{
3.}
4.
5.int (*pFoo)(int) = foo; // assign pFoo to foo()
6.
7.(*pFoo)(nValue); // call function foo(nValue) through pFoo.

The second way is via implicit dereference:
view source
print?
1.int foo(int nX)
2.{
3.}
4.
5.int (*pFoo)(int) = foo; // assign pFoo to foo()
6.
7.pFoo(nValue); // call function foo(nValue) through pFoo.
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Learn C++ - &#187; 7.9 &#8212; The stack and the heap</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-37108</link>
		<dc:creator>Learn C++ - &#187; 7.9 &#8212; The stack and the heap</dc:creator>
		<pubDate>Sun, 11 Jan 2009 22:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-37108</guid>
		<description>[...] 2007      Prev/Next Posts   &#171; 7.8 &#8212; Function Pointers &#124; Home &#124; 7.10 &#8212; Recursion &#187;     Friday, August 10th, 2007 at 4:56 [...]</description>
		<content:encoded><![CDATA[<p>[...] 2007      Prev/Next Posts   &laquo; 7.8 &#8212; Function Pointers | Home | 7.10 &#8212; Recursion &raquo;     Friday, August 10th, 2007 at 4:56 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://www.learncpp.com/cpp-tutorial/78-function-pointers/comment-page-1/#comment-21669</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Thu, 24 Jul 2008 01:33:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.learncpp.com/cpp-tutorial/78-function-pointers/#comment-21669</guid>
		<description>Oops, how did I miss Stuart&#039;s original comments?  In any case, I think it should be fixed now.

Thanks for catching this.</description>
		<content:encoded><![CDATA[<p>Oops, how did I miss Stuart&#8217;s original comments?  In any case, I think it should be fixed now.</p>
<p>Thanks for catching this.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
