<?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[aha, non-class type, obwohl als Klasse definiert?  II]]></title><description><![CDATA[<p>Okay Leute,<br />
ich will gar nicht so tun, als könnte ich es auch alleine schaffen. Hier wäre das nächste Problem. Die Klassendefinitionen stehen im alten Thread, ich denke aber mal nicht, dass die vonnöten sind. Hier meine main-Funktion:</p>
<p>-------------------</p>
<pre><code class="language-cpp">int main(void)
{

        ListenElement Liste[2];

        Liste[0]=ListenElement();
        Liste[1]=IntElement(50,0,0);

        Liste[0].Print();
        Liste[1].Print();

        delete(&amp;Liste[0]); delete(&amp;Liste[1]);
}
</code></pre>
<p>----------------------<br />
Leider führt das delete in der letzten Zeile beim Ausführen der kompilierten Datei zu einer Fehlermeldung:</p>
<p>----------------------------------------<br />
*** glibc detected *** ./a.out: munmap_chunk(): invalid pointer: 0xbf8231d0 ***<br />
======= Backtrace: =========<br />
/lib/tls/i686/cmov/libc.so.6(cfree+0x1bb)[0xb7ce192b]<br />
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb7ea5d81]<br />
./a.out(__gxx_personality_v0+0x21e)[0x8048822]<br />
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7c8a050]<br />
./a.out(__gxx_personality_v0+0x3d)[0x8048641]<br />
======= Memory map: ========</p>
<p>...... und so weiter<br />
--------------------------------------------</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/222516/aha-non-class-type-obwohl-als-klasse-definiert-ii</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 02:54:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/222516.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Sep 2008 17:51:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert?  II on Sat, 13 Sep 2008 17:51:17 GMT]]></title><description><![CDATA[<p>Okay Leute,<br />
ich will gar nicht so tun, als könnte ich es auch alleine schaffen. Hier wäre das nächste Problem. Die Klassendefinitionen stehen im alten Thread, ich denke aber mal nicht, dass die vonnöten sind. Hier meine main-Funktion:</p>
<p>-------------------</p>
<pre><code class="language-cpp">int main(void)
{

        ListenElement Liste[2];

        Liste[0]=ListenElement();
        Liste[1]=IntElement(50,0,0);

        Liste[0].Print();
        Liste[1].Print();

        delete(&amp;Liste[0]); delete(&amp;Liste[1]);
}
</code></pre>
<p>----------------------<br />
Leider führt das delete in der letzten Zeile beim Ausführen der kompilierten Datei zu einer Fehlermeldung:</p>
<p>----------------------------------------<br />
*** glibc detected *** ./a.out: munmap_chunk(): invalid pointer: 0xbf8231d0 ***<br />
======= Backtrace: =========<br />
/lib/tls/i686/cmov/libc.so.6(cfree+0x1bb)[0xb7ce192b]<br />
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0xb7ea5d81]<br />
./a.out(__gxx_personality_v0+0x21e)[0x8048822]<br />
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe0)[0xb7c8a050]<br />
./a.out(__gxx_personality_v0+0x3d)[0x8048641]<br />
======= Memory map: ========</p>
<p>...... und so weiter<br />
--------------------------------------------</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581447</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581447</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 17:51:17 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert?  II on Sat, 13 Sep 2008 17:56:37 GMT]]></title><description><![CDATA[<blockquote>
<pre><code class="language-cpp">delete(&amp;Liste[0]); delete(&amp;Liste[1]);
</code></pre>
</blockquote>
<p><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=":open_mouth:"
      alt="😮"
    /> WTF?</p>
<p>Mal einer, der es umgekehrt macht. <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>delte/delete[] musst du nur machen, wenn du den Speicher explizit selber per new/new[] anforderst. Das wird alles am Ende des Scopes der Definition automatisch erledigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581450</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581450</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 13 Sep 2008 17:56:37 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert?  II on Sat, 13 Sep 2008 18:11:27 GMT]]></title><description><![CDATA[<p>Jau, im Buch war &quot;Liste[2]&quot; eigentlich als Liste von Pointern auf ListenElemente geschrieben und Liste[1/2] waren mit new instanziiert worden.</p>
<p>Soll ich das dahingehend verstehen, dass der Speicher bei Anforderung durch new auch noch nach Ende des ganzen Programmes reserviert und dadurch erstmal unbrauchbar ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581453</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581453</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 18:11:27 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert?  II on Sat, 13 Sep 2008 18:15:00 GMT]]></title><description><![CDATA[<p>Nein, das hat nichts damit zu tun.</p>
<p>Du musst zwischen Stack (automatische, statische Speicherverwaltung) und Heap (dynamische Speicherverwaltung, mit <code>new</code> / <code>new[]</code> angefordert und mit <code>delete</code> / <code>delete[]</code> freigegeben) unterscheiden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581454</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581454</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 13 Sep 2008 18:15:00 GMT</pubDate></item></channel></rss>