<?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[Explizierter Aufruf einer Funktion ohne Beachtung der VTable]]></title><description><![CDATA[<p>Code Beispiel:</p>
<pre><code>struct A
{
    virtual void func() { cout &lt;&lt; &quot;A&quot; &lt;&lt; endl; }
};
struct B : public A
{
    virtual void func() { A::func(); cout &lt;&lt; &quot;B&quot; &lt;&lt; endl; }
};
void invoke_func(A&amp; a)
{
    a.func(); // &lt;= soll A ausgeben und nicht A\nB
}
int main(int argv, char* args)
{
    B b;
    invoke_func(b);
}
</code></pre>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte. Da es aber nur eine reine Compilersache ist, wüsste ich auch nicht, wieso das nicht gehen sollte. Wie mach ich das?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/327878/explizierter-aufruf-einer-funktion-ohne-beachtung-der-vtable</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 17:45:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/327878.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Sep 2014 18:13:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Tue, 09 Sep 2014 18:13:59 GMT]]></title><description><![CDATA[<p>Code Beispiel:</p>
<pre><code>struct A
{
    virtual void func() { cout &lt;&lt; &quot;A&quot; &lt;&lt; endl; }
};
struct B : public A
{
    virtual void func() { A::func(); cout &lt;&lt; &quot;B&quot; &lt;&lt; endl; }
};
void invoke_func(A&amp; a)
{
    a.func(); // &lt;= soll A ausgeben und nicht A\nB
}
int main(int argv, char* args)
{
    B b;
    invoke_func(b);
}
</code></pre>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte. Da es aber nur eine reine Compilersache ist, wüsste ich auch nicht, wieso das nicht gehen sollte. Wie mach ich das?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416718</guid><dc:creator><![CDATA[JulianH]]></dc:creator><pubDate>Tue, 09 Sep 2014 18:13:59 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Tue, 09 Sep 2014 18:23:22 GMT]]></title><description><![CDATA[<pre><code>a.A::func();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2416721</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416721</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Tue, 09 Sep 2014 18:23:22 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Tue, 09 Sep 2014 18:54:01 GMT]]></title><description><![CDATA[<p>Mr.Long schrieb:</p>
<blockquote>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte.</p>
</blockquote>
<p>???<br />
Standardanwendungscase für virtuelle Funktionen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416726</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Tue, 09 Sep 2014 18:54:01 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Tue, 09 Sep 2014 18:59:02 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Mr.Long schrieb:</p>
<blockquote>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte.</p>
</blockquote>
<p>???<br />
Standardanwendungscase für virtuelle Funktionen?</p>
</blockquote>
<p>Ich denke, die richtige Antwort lautet: Ja? <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>
<p>Ist nur igendwie komisch wenn man es noch nie gebraucht hat und dann nach dem Syntax sucht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":O"
      alt="😮"
    /></p>
<p>Danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416727</guid><dc:creator><![CDATA[JulianH]]></dc:creator><pubDate>Tue, 09 Sep 2014 18:59:02 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 16:28:36 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Mr.Long schrieb:</p>
<blockquote>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte.</p>
</blockquote>
<p>???<br />
Standardanwendungscase für virtuelle Funktionen?</p>
</blockquote>
<p>Huch???<br />
Den &quot;Standardanwendungscase&quot; zeigt der OP selbst schon:</p>
<pre><code class="language-cpp">struct B : public A
{
    virtual void func() { A::func(); cout &lt;&lt; &quot;B&quot; &lt;&lt; endl; }
};
</code></pre>
<p>Ergo hat er das nicht gemeint, sondern wirklich den Fall dass man die Funktion non-virtual auf 'was anderes als <code>*this</code> aufrufen will.</p>
<p>Und das ist nun wirklich kein Standardfall. Hab' ich noch genau *nie* gebraucht. Würde ich auch als hochkarätigen Code-Smell einstufen.</p>
<p>EDIT: Verdammte Tippfehler</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416754</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416754</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 10 Sep 2014 16:28:36 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 14:39:42 GMT]]></title><description><![CDATA[<p>Nein, das kommt schon oft vor:</p>
<pre><code>void THE_REMOTE_FILE::purgeItem( void )
{
	THE_ITEM::purgeItem();     // &lt;- rufe version der Basisklasse auf

	PTR_REMOTE_FOLDER parent( getParent() );

	if( !parent-&gt;isRootPurging() )
	{
		try
		{
			DocManService	*theService = getService();
			theService-&gt;sDeleteItem( remoteData.id );
		}
		catch( SoapRequest::SoapException &amp;e )
		{
			STRING	errText = e.faultString;
			if( !e.faultDetail.isEmpty() )
			{
				errText += &quot;: &quot;;
				errText += e.faultDetail;
			}
/*@*/		throw EDatabaseError( (const char *)errText );
		}
		catch( GLIB_ERROR_CODE &amp;errCode )
		{
			const char *cp = getLibraryErrorText( errCode );
			if( !cp )
				cp = &quot;Unkown Library Error&quot;;

/*@*/		throw Exception( cp );
		}
#if 0
		catch( ... )
		{
/*@*/		throw;
		}
#endif
	}
}
</code></pre>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416877</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Wed, 10 Sep 2014 14:39:42 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 15:06:39 GMT]]></title><description><![CDATA[<p>Du musst schon lesen was ich schreibe.</p>
<p>ich schrieb:</p>
<blockquote>
<p>Ergo hat er das nicht gemeint, sondern wirklich den Fall dass man die Funktion non-virtual *<em>auf 'was anderes als <em>this aufrufen will</em></em>.</p>
<p>Und was ist nun wirklich kein Standardfall. Hab' ich noch genau *nie* gebraucht. Würde ich auch als hochkarätigen Code-Smell einstufen.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2416886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416886</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Wed, 10 Sep 2014 15:06:39 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 15:10:43 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Du musst schon lesen was ich schreibe.</p>
<p>ich schrieb:</p>
<blockquote>
<p>Ergo hat er das nicht gemeint, sondern wirklich den Fall dass man die Funktion non-virtual *<em>auf 'was anderes als <em>this aufrufen will</em></em>.</p>
<p>Und was ist nun wirklich kein Standardfall. Hab' ich noch genau *nie* gebraucht. Würde ich auch als hochkarätigen Code-Smell einstufen.</p>
</blockquote>
</blockquote>
<p>Du hast recht. Hab ich überlesen.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416888</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Wed, 10 Sep 2014 15:10:43 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 15:43:05 GMT]]></title><description><![CDATA[<p>mgaeckler schrieb:</p>
<blockquote>
<p>Nein, das kommt schon oft vor:</p>
<pre><code>void THE_REMOTE_FILE::purgeItem( void )
{
	THE_ITEM::purgeItem();     // &lt;- rufe version der Basisklasse auf

	PTR_REMOTE_FOLDER parent( getParent() );

	if( !parent-&gt;isRootPurging() )
	{
		try
		{
			DocManService	*theService = getService();
			theService-&gt;sDeleteItem( remoteData.id );
		}
		catch( SoapRequest::SoapException &amp;e )
		{
			STRING	errText = e.faultString;
			if( !e.faultDetail.isEmpty() )
			{
				errText += &quot;: &quot;;
				errText += e.faultDetail;
			}
/*@*/		throw EDatabaseError( (const char *)errText );
		}
		catch( GLIB_ERROR_CODE &amp;errCode )
		{
			const char *cp = getLibraryErrorText( errCode );
			if( !cp )
				cp = &quot;Unkown Library Error&quot;;

/*@*/		throw Exception( cp );
		}
#if 0
		catch( ... )
		{
/*@*/		throw;
		}
#endif
	}
}
</code></pre>
<p>mfg Martin</p>
</blockquote>
<p>*lach*<br />
Erstmal mit (void) anfangen, damit klar ist, welche Bücher Du liest.</p>
<p>Abgesehen davon haste doch auch nur den Standardfall beschrieben. Klar, daß eine Klassenmethode die passende Basisklassenmethode aufruft, ist ganz normal. Aber daß ein Fremder, vielleicht die main() das macht, das stinkt zum Himmel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416896</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Wed, 10 Sep 2014 15:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to Explizierter Aufruf einer Funktion ohne Beachtung der VTable on Wed, 10 Sep 2014 16:41:15 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Nathan schrieb:</p>
<blockquote>
<p>Mr.Long schrieb:</p>
<blockquote>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte.</p>
</blockquote>
<p>???<br />
Standardanwendungscase für virtuelle Funktionen?</p>
</blockquote>
<p>Huch???<br />
[...]</p>
</blockquote>
<p>Missverständnis meinerseits. Expliziter Aufruf ist natürlich nicht Standardfall.<br />
Ich dachte sein:</p>
<blockquote>
<p>Mir fällt ehrlich gesagt kein Beispiel ein, wieso man das brauchen könnte.</p>
</blockquote>
<p>bezieht sich auf</p>
<blockquote>
<p>soll A ausgeben und nicht A\nB</p>
</blockquote>
<p>, weswegen ich verwirrt reagierte, denn virtueller Aufruf via Referenz ist jetzt der Standardanwendungsfall für virtuelle Funktionen.<br />
Dass es sich auf den expliziten Aufruf bezieht, auf die Idee kam ich nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2416909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2416909</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 10 Sep 2014 16:41:15 GMT</pubDate></item></channel></rss>