<?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[dynamic cast]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe zwei Klassen. Klasse 1 ist die generelle Klasse &quot;Obstacle&quot;. Klasse 2 wird von Klasse 1 abgeleitet und nennt sich &quot;PlanarObstacle&quot;.</p>
<p>Nun habe ich in meinem Programm einen Obstacle-Pointer auf ein Objekt. Zur Laufzeit will ich jetzt herausfinden ob es ein Objekt vom Typ &quot;PlanarObstacle&quot; ist. (Es gibt auch noch andere Typen)</p>
<p>Mein Tutor hat gemeint, dass das folgendermaßen geht:</p>
<pre><code class="language-cpp">PlanarObstacle* Planar3Ptr = dynamic_cast&lt; PlanarObstacle* &gt;( Obstac3Ptr );
</code></pre>
<p>Anschließend kann man dann den Pointer Planar3Ptr überprüfen. Wenn er existiert, ist das Objekt vom Typ &quot;PlanarObstacle&quot;, andernfalls nicht.</p>
<p>Wenn ich das so mache, stürzt das Programm aber an der oben beschriebenen Codestelle ab (unbehandelte Ausnahme). Was mache ich falsch?</p>
<p>Gruß, Amalthea</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/103998/dynamic-cast</link><generator>RSS for Node</generator><lastBuildDate>Thu, 13 Aug 2026 16:29:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/103998.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Mar 2005 12:53:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 12:53:15 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe zwei Klassen. Klasse 1 ist die generelle Klasse &quot;Obstacle&quot;. Klasse 2 wird von Klasse 1 abgeleitet und nennt sich &quot;PlanarObstacle&quot;.</p>
<p>Nun habe ich in meinem Programm einen Obstacle-Pointer auf ein Objekt. Zur Laufzeit will ich jetzt herausfinden ob es ein Objekt vom Typ &quot;PlanarObstacle&quot; ist. (Es gibt auch noch andere Typen)</p>
<p>Mein Tutor hat gemeint, dass das folgendermaßen geht:</p>
<pre><code class="language-cpp">PlanarObstacle* Planar3Ptr = dynamic_cast&lt; PlanarObstacle* &gt;( Obstac3Ptr );
</code></pre>
<p>Anschließend kann man dann den Pointer Planar3Ptr überprüfen. Wenn er existiert, ist das Objekt vom Typ &quot;PlanarObstacle&quot;, andernfalls nicht.</p>
<p>Wenn ich das so mache, stürzt das Programm aber an der oben beschriebenen Codestelle ab (unbehandelte Ausnahme). Was mache ich falsch?</p>
<p>Gruß, Amalthea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/744972</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/744972</guid><dc:creator><![CDATA[Amalthea]]></dc:creator><pubDate>Tue, 15 Mar 2005 12:53:15 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 13:03:08 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>der Aufruf selber ist in Ordnung, bist du denn sicher, das Obstac3Ptr eine gültige Instanz egal welchen Types ist oder NULL?<br />
Mit anderen Worten : hast du einen sinnvollen Wert zugewiesen?</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/744983</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/744983</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Tue, 15 Mar 2005 13:03:08 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 13:10:28 GMT]]></title><description><![CDATA[<p>Ja, bin mir sicher... hab es gerade noch mal überprüft...</p>
<p>Also nachdem mein oben geschriebener Code aufgerufen wurde, springt das Programm nach einigen Schritten an folgende Stelle (--&gt;) und stürzt ab..</p>
<pre><code class="language-cpp">_CRTIMP void * __cdecl malloc (
        size_t nSize
        )
{
--&gt;      void *res = _nh_malloc_dbg(nSize, _newmode, _NORMAL_BLOCK, NULL, 0);

        RTCCALLBACK(_RTC_Allocate_hook, (res, nSize, 0));

        return res;
}
</code></pre>
<p>Diese Codestelle befindet sich in &quot;dbgheap.c&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/744992</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/744992</guid><dc:creator><![CDATA[Amalthea]]></dc:creator><pubDate>Tue, 15 Mar 2005 13:10:28 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 13:48:26 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>da der Fehler anscheined nach dem Cast kommt :<br />
hast du denn mal das Ergebnis des Casts überprüft? Also so hier</p>
<pre><code class="language-cpp">if (Planar3Ptr != NULL)
{
  // Tue etwas mit Planar3Ptr
  }
else
{
  // Tue etwas, wenn Umwandlung nicht möglich
  }
</code></pre>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745024</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745024</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Tue, 15 Mar 2005 13:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 14:55:04 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich kann das Ergebnis des Casts nicht überprüfen, da der Fehler kommt, bevor die nächste Zeile von &quot;meinem&quot; Code aufgerufen wird...</p>
<p>Die Codestelle in meinem zweiten Post wird durch meine Codestelle aufgerufen. Ist aber nicht von mir programmmiert.... das steht in irendeiner bestehenden dll.<br />
Das ist der letzte Aufruf der stattfindet:<br />
msvcr71d.dll!malloc(unsigned int nSize=3765269347) Zeile 139 + 0x15 C<br />
bevor das programm abstürzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745123</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745123</guid><dc:creator><![CDATA[Amalthea]]></dc:creator><pubDate>Tue, 15 Mar 2005 14:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Tue, 15 Mar 2005 16:11:40 GMT]]></title><description><![CDATA[<p>Mal geraten - übersetzt Du deine Anwendung mit RTTI? Ich meine, das muss man beim Visual Studio manuell aktivieren. (entnehme ich jetzt mal der Angabe, dass er in der msvcr71d.dll abstürzt)</p>
<p>RTTI (RunTime Type Information) ist notwendig, damit dynamic_casts funktionieren können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745214</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Tue, 15 Mar 2005 16:11:40 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Wed, 16 Mar 2005 07:47:35 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>hm, hab ich jetzt eingestellt. Das Programm stürzt aber trotzdem ab...</p>
<p>Gruß, Amalthea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745637</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745637</guid><dc:creator><![CDATA[Amalthea]]></dc:creator><pubDate>Wed, 16 Mar 2005 07:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Wed, 16 Mar 2005 08:52:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">PlanarObstacle* Planar3Ptr = dynamic_cast&lt; PlanarObstacle* &gt;( Obstac3Ptr );
</code></pre>
<p>Bist Du Dir denn auch sicher, dass Obstac3Ptr vorher auf etwas gültiges zeigt?<br />
Sonst poste mal ein wenig vom umliegenden Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745692</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745692</guid><dc:creator><![CDATA[7H3 N4C3R]]></dc:creator><pubDate>Wed, 16 Mar 2005 08:52:51 GMT</pubDate></item><item><title><![CDATA[Reply to dynamic cast on Wed, 16 Mar 2005 09:37:20 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>es funktioniert jetzt. Ich glaub es lag doch an den Projekteinstellungen, da ich sonst nichts geändert habe.</p>
<p>Danke für den Tipp.</p>
<p>Gruß, Amalthea</p>
]]></description><link>https://www.c-plusplus.net/forum/post/745742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/745742</guid><dc:creator><![CDATA[Amalthea]]></dc:creator><pubDate>Wed, 16 Mar 2005 09:37:20 GMT</pubDate></item></channel></rss>