<?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[Verwendung von Listen]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich erstelle zur Laufzeit n Objekte vom Typ &quot;myCube&quot;. Diese will ich in einer Liste verwalten. Kann mir jemand sagen, wie ich so eine Liste verwalten kann? Ich konnte keine Codebeispiele finden.</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/215460/verwendung-von-listen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 11 Oct 2026 13:44:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/215460.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 11 Jun 2008 11:14:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:14:11 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich erstelle zur Laufzeit n Objekte vom Typ &quot;myCube&quot;. Diese will ich in einer Liste verwalten. Kann mir jemand sagen, wie ich so eine Liste verwalten kann? Ich konnte keine Codebeispiele finden.</p>
<p>Gruß<br />
Alex</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526942</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:14:11 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:18:58 GMT]]></title><description><![CDATA[<p>Was heisst denn &quot;verwalten&quot;?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526945</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526945</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:18:58 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:21:53 GMT]]></title><description><![CDATA[<p>Naja, ich brauche eine Möglichkeit durch alle Objekte zu laufen und ein bestimmtes rauspicken zu können. Man könnte auch ein array nehmen, aber ich kenne die Anzahl der Elemente, die rein sollen, erst zur Laufzeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526947</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526947</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:21:53 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:26:32 GMT]]></title><description><![CDATA[<p>Nimm die dynamischen STL-Container, zum Beispiel <code>std::vector&lt;&gt;</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526950</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:26:32 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:27:46 GMT]]></title><description><![CDATA[<p>zu langsam...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526952</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526952</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:27:46 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:28:58 GMT]]></title><description><![CDATA[<p>Vielen Dank!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526953</guid><dc:creator><![CDATA[filth]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:28:58 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:34:07 GMT]]></title><description><![CDATA[<p>Hier wäre eine gute Referenz (englisch) dazu: <a href="http://www.cplusplus.com/reference/stl/vector/" rel="nofollow">http://www.cplusplus.com/reference/stl/vector/</a><br />
Links auf der Seite siehst du gleich noch die anderen Containertemplates (z.B. <code>std::deque&lt;&gt;</code> ).</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-143816.html" rel="nofollow">In diesem Artikel</a> des Forums ist auch eine sehr gute Beschreibung der einzelnen Container, da kannst du abschätzen, welchen du am ehesten verwenden sollst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526955</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:34:07 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:34:31 GMT]]></title><description><![CDATA[<pre><code>typedef std::list&lt;boost::shared_ptr&lt;my_object&gt; &gt; container;
container c;
.
mit objekten füllen 
.
containter::const_iterator it=c.begin();
while(it!=c.end()){
    .
    bla-bla
    .
    ++it;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1526956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526956</guid><dc:creator><![CDATA[kitov]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:34:31 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Wed, 11 Jun 2008 11:49:03 GMT]]></title><description><![CDATA[<p>Ich wage mal zu bezweifeln, dass der boost::shared_ptr hier irgendwie Klarheit verschafft...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1526963</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1526963</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Wed, 11 Jun 2008 11:49:03 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Thu, 12 Jun 2008 06:37:25 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::list&lt;myobject*&gt; mylist;
std::list&lt;myobject*&gt;::iterator pos;

//einfügen
mylist.push_back(new myobject());

//mylist.end() ist keines der Objekte
for (pos=mylist.begin(); pos!=mylist.end(); ++pos)
{
	(*pos)-&gt;wasauchimmer();
}

//löschen
for (pos=mylist.begin(); pos!=mylist.end(); ++pos)
{
	delete *pos; //Objekt tatsächlich löschen
	mylist.erase(pos--); //beim löschen Dekrementieren sonst würde ein Objekt übersprungen
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1527388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1527388</guid><dc:creator><![CDATA[debian inside]]></dc:creator><pubDate>Thu, 12 Jun 2008 06:37:25 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Thu, 12 Jun 2008 08:08:06 GMT]]></title><description><![CDATA[<p>Warum machst du es mit Zeigern, wenn du die Elemente sowieso neu erstellst? Das macht die ganze Sache nur komplizierter...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1527439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1527439</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 12 Jun 2008 08:08:06 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 08:45:57 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Warum machst du es mit Zeigern, wenn du die Elemente sowieso neu erstellst? Das macht die ganze Sache nur komplizierter...</p>
</blockquote>
<p>Weil die Objekte zbsp in ner Schleife oder Funktion erzeugt werden und um zu verhindern das die Objekte gleich wieder gelöscht werden wird man wohl Zeiger verwenden.<br />
Auserdem ist es in diesem Fall wichtig vorher die Objekte zu löschen und dann erst den Listeneintrag sonst hat man keinen Zugriff mehr und das wollte ich einbringen in dem Beispiel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533157</guid><dc:creator><![CDATA[debian inside]]></dc:creator><pubDate>Sat, 21 Jun 2008 08:45:57 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 09:03:23 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Warum machst du es mit Zeigern, wenn du die Elemente sowieso neu erstellst? Das macht die ganze Sache nur komplizierter...</p>
<p>debian inside schrieb:</p>
<blockquote>
<p>Weil die Objekte zbsp in ner Schleife oder Funktion erzeugt werden</p>
</blockquote>
</blockquote>
<p>word! <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12954">@Nexus</a><br />
wayne? <a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/3689">@linux</a> ^^</p>
<pre><code class="language-cpp">#include &lt;list&gt;

std::list &lt;myobject&gt; mylist;

for (int i (0); i != MAX; ++i)
{
mylist.push_back (myobject ());
}
</code></pre>
<p>debian inside schrieb:</p>
<blockquote>
<p>Auserdem ist es in diesem Fall wichtig vorher die Objekte zu löschen und dann erst den Listeneintrag sonst hat man keinen Zugriff mehr</p>
</blockquote>
<p>glaub ich nicht...</p>
<pre><code class="language-cpp">//iter == irgend nen mylist-iterator
mylist.earase (iter);
</code></pre>
<p>reicht völlig aus... dein argument zieht nur, wenn man iwas threaded machen muss - und dann braucht man eh nen lock auf der gesamten liste, wenn man was löscht...</p>
<p>bb</p>
<p>PS: Ich kann mich auch irren - aber kann ich mir nicht so recht vorstellen (also das ich jemals falsch liegen würde <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=";D"
      alt="😉"
    /> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533163</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 21 Jun 2008 09:03:23 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 11:17:47 GMT]]></title><description><![CDATA[<p>In dieser Schleife wird sofort nach dem Konstruktor der Destruktor aufgerufen und beim list::erase ohne vorher das Objekt richtig zu löschen wird nie der Destruktor aufgerufen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533164</guid><dc:creator><![CDATA[debian inside]]></dc:creator><pubDate>Sat, 21 Jun 2008 11:17:47 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 10:24:45 GMT]]></title><description><![CDATA[<p>Bei push_back in der Schleife wird mittels Konstruktor ein temporäres Objekt erzeugt. Dies wird dann per CopyCtor in den vector kopiert und dann wird das temporäre Objekt per Destruktor wieder zerstört. So gesehen ist alles ok.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533194</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533194</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Sat, 21 Jun 2008 10:24:45 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 11:01:13 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Bei push_back in der Schleife wird mittels Konstruktor ein temporäres Objekt erzeugt. Dies wird dann per CopyCtor in den vector kopiert und dann wird das temporäre Objekt per Destruktor wieder zerstört. So gesehen ist alles ok.</p>
</blockquote>
<p>Danke das hab ich noch nicht gewusst und erklärt auch einiges. <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="😉"
    /><br />
Aber wenn ich trozdem Zeiger verwende muss ich beim Aufruf von list::erase() den Destruktor mit delete aufrufen oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533205</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533205</guid><dc:creator><![CDATA[debian inside]]></dc:creator><pubDate>Sat, 21 Jun 2008 11:01:13 GMT</pubDate></item><item><title><![CDATA[Reply to Verwendung von Listen on Sat, 21 Jun 2008 11:12:42 GMT]]></title><description><![CDATA[<p>Genau richtig. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1533209</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1533209</guid><dc:creator><![CDATA[Fencer]]></dc:creator><pubDate>Sat, 21 Jun 2008 11:12:42 GMT</pubDate></item></channel></rss>