<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Zeiger auf Elementfunktionen]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Wie erstelle ich einen Funktionszeiger auf eine Methode welche in einer Klasse<br />
deklariert ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/184617/zeiger-auf-elementfunktionen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 20:19:10 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/184617.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Jun 2007 13:24:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 13:24:48 GMT]]></title><description><![CDATA[<p>Hey Leute,</p>
<p>Wie erstelle ich einen Funktionszeiger auf eine Methode welche in einer Klasse<br />
deklariert ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307678</guid><dc:creator><![CDATA[_carnage]]></dc:creator><pubDate>Sun, 17 Jun 2007 13:24:48 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 13:37:53 GMT]]></title><description><![CDATA[<p><a href="http://www.function-pointer.org/" rel="nofollow">http://www.function-pointer.org/</a><br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307686</guid><dc:creator><![CDATA[pale dog]]></dc:creator><pubDate>Sun, 17 Jun 2007 13:37:53 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 14:06:05 GMT]]></title><description><![CDATA[<p>hm hab das jez so gemacht:</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;

class A {
private:
  void test1() { printf(&quot;A::1\n&quot;); };
  void test2() { printf(&quot;A::2\n&quot;); };
public:
	typedef void (*A::A_f)();
 A_f test;
 void exec(int i);
};

void A::exec(int i) {
 switch(i) {
  case 1:
   test = &amp;test1;
   break;
 case 2:
   test = &amp;test2;
   break;
 }
}

int main( int argc, char **argv ) {
	A a;

	a.exec(1);
	a.exec(2);

	return 0;

}
}
</code></pre>
<p>//funktioniert aber irgendwie nicht &gt;&gt;<br />
error C2276: '&amp;' : illegal operation on bound member function expression<br />
error C2276: '&amp;' : illegal operation on bound member function expression<br />
beides bei den Zuweisungen von test</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307705</guid><dc:creator><![CDATA[_carnage]]></dc:creator><pubDate>Sun, 17 Jun 2007 14:06:05 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 14:08:39 GMT]]></title><description><![CDATA[<p>_carnage schrieb:</p>
<blockquote>
<pre><code class="language-cpp">...
   typedef void (*A::A_f)();
...
   test = &amp;test1;
...
</code></pre>
</blockquote>
<pre><code class="language-cpp">...
   typedef void (A::*A_f)();
...
   test = &amp;A::test1;
...
</code></pre>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307712</guid><dc:creator><![CDATA[pale dog]]></dc:creator><pubDate>Sun, 17 Jun 2007 14:08:39 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 15:08:50 GMT]]></title><description><![CDATA[<p>und wenn ich test() aufrufe sagt der Compiler aber:<br />
&quot;error C2064: term does not evaluate to a function&quot;</p>
<p>was heisst das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307769</guid><dc:creator><![CDATA[_carnage]]></dc:creator><pubDate>Sun, 17 Jun 2007 15:08:50 GMT</pubDate></item><item><title><![CDATA[Reply to Zeiger auf Elementfunktionen on Sun, 17 Jun 2007 15:28:25 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;string&gt;

struct foo
{
	typedef void ( foo::*fun_ptr )() const;

private:
	void test1() const { std::cout &lt;&lt; &quot;foo::test1()&quot; &lt;&lt; std::endl; }
	void test2() const { std::cout &lt;&lt; &quot;foo::test2()&quot; &lt;&lt; std::endl; }

public:
	void exec( unsigned index )
	{
		assert( index &lt; 2 );

		static fun_ptr functions[] =
		{
			&amp;foo::test1,
			&amp;foo::test2
		};

		( *this.*functions[ index ] )();
	}
};

int main()
{
	foo bar;

	bar.exec( 0 );
	bar.exec( 1 );

	std::cin.get();
}
</code></pre>
<p>Bei Methodenfunktionszeigern brauchst du natürlich auch eine gültige Instanz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1307780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1307780</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Sun, 17 Jun 2007 15:28:25 GMT</pubDate></item></channel></rss>