<?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[std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...?]]></title><description><![CDATA[<p>Hi,<br />
ich habe folgenden Code:</p>
<pre><code class="language-cpp">Test GetNext( void )
{
	if ( !m_List.empty() )
	{
		if ( m_ListIt == NULL )
		{
			m_ListIt = m_List.begin();	// Problem: Warum Crash!?

			if ( m_ListIt != m_List.end() )
				m_ListIt++;

			return (*m_ListIt);
		}
	}
	else
	{
		return NULL;
	}
}
</code></pre>
<p>Wie mache ich das richtig? Ich habe das Problem, dass es einen Crash gibt, ich will halt mit der Funktion immer das nächste Element in der Liste zurückgegeben bekommen.</p>
<p>Danke im Voraus</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/164092/std-list-lt-gt-nächstes-element-in-der-liste</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 19:04:58 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/164092.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 05 Nov 2006 01:36:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Sun, 05 Nov 2006 01:36:21 GMT]]></title><description><![CDATA[<p>Hi,<br />
ich habe folgenden Code:</p>
<pre><code class="language-cpp">Test GetNext( void )
{
	if ( !m_List.empty() )
	{
		if ( m_ListIt == NULL )
		{
			m_ListIt = m_List.begin();	// Problem: Warum Crash!?

			if ( m_ListIt != m_List.end() )
				m_ListIt++;

			return (*m_ListIt);
		}
	}
	else
	{
		return NULL;
	}
}
</code></pre>
<p>Wie mache ich das richtig? Ich habe das Problem, dass es einen Crash gibt, ich will halt mit der Funktion immer das nächste Element in der Liste zurückgegeben bekommen.</p>
<p>Danke im Voraus</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1168634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1168634</guid><dc:creator><![CDATA[INeedHelpAgain]]></dc:creator><pubDate>Sun, 05 Nov 2006 01:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Sun, 05 Nov 2006 02:44:30 GMT]]></title><description><![CDATA[<p>Hab vergessen... Der Fehler ist: <strong>list iterators incompatible</strong></p>
<p>Danke</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1168642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1168642</guid><dc:creator><![CDATA[INeedHelpAgain]]></dc:creator><pubDate>Sun, 05 Nov 2006 02:44:30 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Sun, 05 Nov 2006 08:43:42 GMT]]></title><description><![CDATA[<p>(Eins vorweg: der Code sieht durch und durch unsinnig aus.)</p>
<p>Crash oder Compiler-Fehler? Fehlermeldung? Deklaration von m_ListIt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1168659</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1168659</guid><dc:creator><![CDATA[finix]]></dc:creator><pubDate>Sun, 05 Nov 2006 08:43:42 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Sun, 05 Nov 2006 10:55:28 GMT]]></title><description><![CDATA[<p>INeedHelpAgain schrieb:</p>
<blockquote>
<p>Hab vergessen... Der Fehler ist: <strong>list iterators incompatible</strong></p>
</blockquote>
<p>Damit sollte doch auch schon klar sein, wo der Fehler liegt, oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1168725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1168725</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Sun, 05 Nov 2006 10:55:28 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Mon, 06 Nov 2006 08:31:50 GMT]]></title><description><![CDATA[<p>Erstmal hast du deine Verschachtelungen irgendwie falsch verknotet - wenn m_ListIt gleich NULL ist, lieferst du letztendlich das zeite Listenelement (oder dereferenzierst end() - böse Sache), andernfalls umgehst du elegant alle return's (das heißt, dort kommt Müll raus).</p>
<p>Zweitens ist ein list&lt;&gt;::iterator KEIN Zeiger, also ist der Vergleich auf NULL vermutlich Nonsens.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1169392</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1169392</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 06 Nov 2006 08:31:50 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Tue, 07 Nov 2006 02:28:52 GMT]]></title><description><![CDATA[<p>Oha, ja, das schreit nach einer &quot;not all control pahts return a value&quot; Warning. Ist mir garnicht aufgefallen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170144</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 07 Nov 2006 02:28:52 GMT</pubDate></item><item><title><![CDATA[Reply to std::list&amp;lt;...&amp;gt; Nächstes Element in der Liste...? on Tue, 07 Nov 2006 05:04:32 GMT]]></title><description><![CDATA[<p>Irgendwie ist der Code sinnlos...<br />
Du schreibst einen Iterator für einen Iterator?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1170150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1170150</guid><dc:creator><![CDATA[DEvent]]></dc:creator><pubDate>Tue, 07 Nov 2006 05:04:32 GMT</pubDate></item></channel></rss>