<?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[funktionspointer problem]]></title><description><![CDATA[<p>Problem:</p>
<pre><code class="language-cpp">class foo
{
    public:
    long func ();
};

int main ()
{
    long (*PointerToFunc) ();
    foo bar;

    PointerToFunc = bar.func; // oops, das funzt nicht
}
</code></pre>
<p>Lösung 1:</p>
<pre><code class="language-cpp">class foo
{
    public:
    long func ();
};

foo bar;

long tempfunc ()
{ return bar.func (); }

int main ()
{
    long (*PointerToFunc) ();

    PointerToFunc = tempfunc; 
}
</code></pre>
<p>Wie mal leicht sehen kann, bin ich damit nicht glücklich. bar muss Global sein, und es wird eine zusätzliche Funktion benötigt. casten hab ich versucht, hat nicht geklappt. Hat jemand ne elegante Methode?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/125856/funktionspointer-problem</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 12:53:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/125856.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 09 Nov 2005 22:04:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to funktionspointer problem on Wed, 09 Nov 2005 22:04:42 GMT]]></title><description><![CDATA[<p>Problem:</p>
<pre><code class="language-cpp">class foo
{
    public:
    long func ();
};

int main ()
{
    long (*PointerToFunc) ();
    foo bar;

    PointerToFunc = bar.func; // oops, das funzt nicht
}
</code></pre>
<p>Lösung 1:</p>
<pre><code class="language-cpp">class foo
{
    public:
    long func ();
};

foo bar;

long tempfunc ()
{ return bar.func (); }

int main ()
{
    long (*PointerToFunc) ();

    PointerToFunc = tempfunc; 
}
</code></pre>
<p>Wie mal leicht sehen kann, bin ich damit nicht glücklich. bar muss Global sein, und es wird eine zusätzliche Funktion benötigt. casten hab ich versucht, hat nicht geklappt. Hat jemand ne elegante Methode?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913419</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913419</guid><dc:creator><![CDATA[N00Bie]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:04:42 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Wed, 09 Nov 2005 22:08:42 GMT]]></title><description><![CDATA[<p>Die Dinger für Methoden heißen dann logischerweise Methodenpointer.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913422</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913422</guid><dc:creator><![CDATA[FireFlow]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:08:42 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Wed, 09 Nov 2005 22:10:37 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>siehe Suche. Da hab ich zum Beispiel <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-121538-and-highlight-is-funktionspointer.html" rel="nofollow">das</a> gefunden.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913426</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913426</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:10:37 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Wed, 09 Nov 2005 22:23:44 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;
class foo
{
    public:
    long func ()
    { 
         std::cout &lt;&lt; &quot;Called Method: long foo::func() and return value = &quot;; 
         return 10; 
    }
};

int main ()
{
    // Zeiger auf Methode func() von foo
    long (foo::*PointerToFunc) (); 
    foo bar;
    // Methodenzeiger zuweisen
    PointerToFunc = &amp;foo::func; 
    // Methodenzeiger aufrufen
    std::cout &lt;&lt; (bar.*PointerToFunc)() &lt;&lt; std::endl;   
}
</code></pre>
<p>Edit: Btw Hurra die 1000 sind voll *g*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913436</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913436</guid><dc:creator><![CDATA[evilissimo]]></dc:creator><pubDate>Wed, 09 Nov 2005 22:23:44 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Thu, 10 Nov 2005 10:22:57 GMT]]></title><description><![CDATA[<p>oh, ich hab vergessen zu erwähnen, dass der Funktionspointer nicht verändert werden darf. Denn er kommt aus eine dll, die ich nicht selbst geschrieben habe. Sonst wär meine Frage wirklich n bisser dümmlich, geb ich zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913711</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913711</guid><dc:creator><![CDATA[N00Bie]]></dc:creator><pubDate>Thu, 10 Nov 2005 10:22:57 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Thu, 10 Nov 2005 12:20:41 GMT]]></title><description><![CDATA[<p>Dann brauchst Du aber eine Möglichkeit das dazugehörige Objekt zu identifizieren. Dein Callback gibt anscheinend keine Möglichkeit dazu.</p>
<p>Üblicherweise sind solche Callback-APIs so gehalten, dass man einen Wert beim Registrieren mitgibt, der bei jedem Aufruf des Callbacks wieder zurückgegeben wird.</p>
<p>In deinem Fall hilft Dir vielleicht ein Singleton weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/913811</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/913811</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Thu, 10 Nov 2005 12:20:41 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Thu, 10 Nov 2005 17:56:11 GMT]]></title><description><![CDATA[<p>*schäm* ich muss feststellen, dass ich heute die selbe Frage neu gestellt hab...<br />
Aber irgendwie ist die Suchfunktion auch nicht so ideal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
<p>Also, hier meine Lösung:</p>
<pre><code class="language-cpp">class Test {
public:
	void foo () {
		return;
	}
};

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow )
{

	Test t;
	void (Test::*pTestFkt)();
	pTestFkt = &amp;Test::foo;
	(t.*pTestFkt)();

	return 0;
}
</code></pre>
<p>Das klappt bei mir.</p>
<p>Viele Grüße,</p>
<p>Matthias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914176</guid><dc:creator><![CDATA[fehlersucher]]></dc:creator><pubDate>Thu, 10 Nov 2005 17:56:11 GMT</pubDate></item><item><title><![CDATA[Reply to funktionspointer problem on Thu, 10 Nov 2005 21:43:12 GMT]]></title><description><![CDATA[<p>fehlersucher schrieb:</p>
<blockquote>
<p>*schäm* ich muss feststellen, dass ich heute die selbe Frage neu gestellt hab...<br />
Aber irgendwie ist die Suchfunktion auch nicht so ideal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";-)"
      alt="😉"
    /></p>
<p>Also, hier meine Lösung:</p>
<pre><code class="language-cpp">class Test {
public:
	void foo () {
		return;
	}
};

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow )
{

	Test t;
	void (Test::*pTestFkt)();
	pTestFkt = &amp;Test::foo;
	(t.*pTestFkt)();

	return 0;
}
</code></pre>
<p>Das klappt bei mir.</p>
<p>Viele Grüße,</p>
<p>Matthias</p>
</blockquote>
<p>klar, bei mir auch!<br />
Leider kann ich aber keinen solchen Pointer verwenden, da ich den vorgefertigten verwenden muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/914431</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/914431</guid><dc:creator><![CDATA[N00Bie]]></dc:creator><pubDate>Thu, 10 Nov 2005 21:43:12 GMT</pubDate></item></channel></rss>