<?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[über pointer2member eine virtuelle funktion aufrufen]]></title><description><![CDATA[<p>hi,<br />
wie kann ich über einen pointer2member eine virtuelle funktion aufrufen? brauch ich da paar tricks, denn virtual sagt ja erst zur runtime welche funktion aufgerufen wird...</p>
<p>cu</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/157483/über-pointer2member-eine-virtuelle-funktion-aufrufen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 02:33:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/157483.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Aug 2006 11:41:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 11:41:06 GMT]]></title><description><![CDATA[<p>hi,<br />
wie kann ich über einen pointer2member eine virtuelle funktion aufrufen? brauch ich da paar tricks, denn virtual sagt ja erst zur runtime welche funktion aufgerufen wird...</p>
<p>cu</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124867</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Sat, 26 Aug 2006 11:41:06 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 11:51:12 GMT]]></title><description><![CDATA[<p>Hallo,<br />
da sind keine Tricks notwendig, der Pointer ist in diesem Fall kein echter Pointer, sondern ein Datentyp, der alle notwendigen Informationen enthält:</p>
<pre><code class="language-cpp">class Base {
public:
	virtual void f() {
		cout &lt;&lt; &quot;Base::f&quot; &lt;&lt; endl;
	}
};

class  Derived : public Base {
public:
	void f() {
		cout &lt;&lt; &quot;Derived::f&quot; &lt;&lt; endl;
	}

};

int main(){
	void (Base::*pm)() = &amp;Base::f;
	Derived d;
	Base&amp; b = d;
	(b.*pm)();	// Derived::f
	(d.*pm)();  // Derived::f
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1124870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124870</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sat, 26 Aug 2006 11:51:12 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 12:09:25 GMT]]></title><description><![CDATA[<p>interessant;)<br />
könnte man da auch was mit boost::function machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124880</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124880</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Sat, 26 Aug 2006 12:09:25 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 12:17:09 GMT]]></title><description><![CDATA[<p>boost::bind(boost::mem_fun(&amp;Base::f), object);</p>
<p>Dann hast du ein Functor, wie man den in boost::function bekommt weiß ich nicht (noch nie gemacht).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124885</guid><dc:creator><![CDATA[Thomas ** 0]]></dc:creator><pubDate>Sat, 26 Aug 2006 12:17:09 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 12:37:34 GMT]]></title><description><![CDATA[<p>îch will doch keinen functor haben! nur so ne art funktionspointer mit boost::function...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124891</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124891</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Sat, 26 Aug 2006 12:37:34 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 12:57:06 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">boost::function f(boost::bind(&amp;Klasse::Memberfunktion, pObject));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1124907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124907</guid><dc:creator><![CDATA[??????]]></dc:creator><pubDate>Sat, 26 Aug 2006 12:57:06 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sat, 26 Aug 2006 14:15:02 GMT]]></title><description><![CDATA[<p>geht das ohne boost::bind nicht? so ca.:</p>
<pre><code class="language-cpp">class foo 
{ 
public:
	virtual void bar(int x)
	{
		cout &lt;&lt; &quot;foo::bar &quot; &lt;&lt; x &lt;&lt; endl;
	}
}; 

class quu : foo 
{ 
public:
	void bar(int x)
	{
		cout &lt;&lt; &quot;quu::bar &quot; &lt;&lt; x &lt;&lt; endl;
	}
};

int main()
{
	boost::function2&lt;void, foo*, int&gt; f;
	f = &amp;foo::bar;
	quu x;
	f(&amp;x, 5);
        cin.get();
</code></pre>
<p>error C2243: 'type cast' : conversion from 'quu *__w64 ' to 'foo *' exists, but is inaccessible</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1124941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1124941</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Sat, 26 Aug 2006 14:15:02 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sun, 27 Aug 2006 08:09:39 GMT]]></title><description><![CDATA[<p>quu muss öffentlich von foo erben, damit quu implizit nach foo konvertierbar. Du erbst in deinem Beispiel aber privat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125222</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125222</guid><dc:creator><![CDATA[HumeSikkins]]></dc:creator><pubDate>Sun, 27 Aug 2006 08:09:39 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sun, 27 Aug 2006 08:43:30 GMT]]></title><description><![CDATA[<p>hm, upps;/<br />
weisst du wie boost::function intern funktioniert?</p>
<p>ist das hier die einzige erkläreung wie das in etwas intern abläuft?<br />
In Boost.Function, an alternative but equivalent approach was taken using free functions instead of virtual functions. The Boost.Function object essentially holds two pointers to make a valid target call: a void pointer to the function object it contains and a void pointer to an &quot;invoker&quot; that can call the function object, given the function pointer. This invoker function performs the argument and return value conversions Boost.Function provides. A third pointer points to a free function called the &quot;manager&quot;, which handles the cloning and destruction of function objects. The scheme is typesafe because the only functions that actually handle the function object, the invoker and the manager, are instantiated given the type of the function object, so they can safely cast the incoming void pointer (the function object pointer) to the appropriate type.</p>
<p>cu</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125231</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125231</guid><dc:creator><![CDATA[cpp1]]></dc:creator><pubDate>Sun, 27 Aug 2006 08:43:30 GMT</pubDate></item><item><title><![CDATA[Reply to über pointer2member eine virtuelle funktion aufrufen on Sun, 27 Aug 2006 09:26:57 GMT]]></title><description><![CDATA[<p>Steht da doch, so wie man eben member-function-pointer aufruft mit dem .* und dem -&gt;* operator (ein beispiel sieht du ja weiter oben im thread von hume).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1125237</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1125237</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Sun, 27 Aug 2006 09:26:57 GMT</pubDate></item></channel></rss>