<?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[N-tes Element in einer einfach-verketteten Liste löschen...]]></title><description><![CDATA[<p>Hi,</p>
<p>Also ich möchte ein beliebig positioniertes Element in einer einfach verketteten Liste löschen.</p>
<p>Mein Code sieht bisher so aus:</p>
<pre><code class="language-cpp">void CList::Delete(unsigned int uiPos)
	{
		if(!uiPos)
		{
			CEntry* pTemp = _pFirst;
			_pFirst = _pFirst-&gt;_pNext;
			delete pTemp;
		}
		else
		{
			CEntry *pCell = _pFirst,
					  *pNext = NULL;
			for(unsigned int uiCount = 0; pCell != NULL; pCell = pNext, uiCount++)
			{
				pNext = pCell-&gt;_pNext;
				if(uiCount == uiPos)
				{
					CEntry* pTemp = pCell;
					pCell = pCell-&gt;_pNext;
					delete pTemp;
					break;
				}
			}
		}
	}
</code></pre>
<p>Das Problem ist, das er beim Abbauen des Objekts (also beim Aufruf des Destruktors) immer abstürtzt (Speicherzugriffsverletzung). Genauer: Beim delete.</p>
<p>Der Destruktor sieht so aus:</p>
<pre><code class="language-cpp">CList::~CList(void)
	{
		CEntry *pCell = _pFirst,
				  *pNext = NULL;
		for( ; pCell != NULL; pCell = pNext)
		{
			pNext = pCell-&gt;_pNext;
			delete pCell;
		}
	}
</code></pre>
<p>Ich hoffe ihr könnt mir helfen, danke schonmal <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>
]]></description><link>https://www.c-plusplus.net/forum/topic/168642/n-tes-element-in-einer-einfach-verketteten-liste-löschen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 12:43:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/168642.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Dec 2006 23:41:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to N-tes Element in einer einfach-verketteten Liste löschen... on Mon, 25 Dec 2006 23:41:59 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>Also ich möchte ein beliebig positioniertes Element in einer einfach verketteten Liste löschen.</p>
<p>Mein Code sieht bisher so aus:</p>
<pre><code class="language-cpp">void CList::Delete(unsigned int uiPos)
	{
		if(!uiPos)
		{
			CEntry* pTemp = _pFirst;
			_pFirst = _pFirst-&gt;_pNext;
			delete pTemp;
		}
		else
		{
			CEntry *pCell = _pFirst,
					  *pNext = NULL;
			for(unsigned int uiCount = 0; pCell != NULL; pCell = pNext, uiCount++)
			{
				pNext = pCell-&gt;_pNext;
				if(uiCount == uiPos)
				{
					CEntry* pTemp = pCell;
					pCell = pCell-&gt;_pNext;
					delete pTemp;
					break;
				}
			}
		}
	}
</code></pre>
<p>Das Problem ist, das er beim Abbauen des Objekts (also beim Aufruf des Destruktors) immer abstürtzt (Speicherzugriffsverletzung). Genauer: Beim delete.</p>
<p>Der Destruktor sieht so aus:</p>
<pre><code class="language-cpp">CList::~CList(void)
	{
		CEntry *pCell = _pFirst,
				  *pNext = NULL;
		for( ; pCell != NULL; pCell = pNext)
		{
			pNext = pCell-&gt;_pNext;
			delete pCell;
		}
	}
</code></pre>
<p>Ich hoffe ihr könnt mir helfen, danke schonmal <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1197844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197844</guid><dc:creator><![CDATA[Timmy]]></dc:creator><pubDate>Mon, 25 Dec 2006 23:41:59 GMT</pubDate></item><item><title><![CDATA[Reply to N-tes Element in einer einfach-verketteten Liste löschen... on Tue, 26 Dec 2006 07:36:39 GMT]]></title><description><![CDATA[<p>Es muss eher so sein:</p>
<pre><code class="language-cpp">prev-&gt;next = pcell-&gt;next;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1197897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1197897</guid><dc:creator><![CDATA[David_pb]]></dc:creator><pubDate>Tue, 26 Dec 2006 07:36:39 GMT</pubDate></item></channel></rss>