<?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[Array allokieren und alle Objekte benennen]]></title><description><![CDATA[<p>Servus,</p>
<p>ich habe einen Zeiger Patch* p und will nun ein Array von Patches anlegen. z.b. so:</p>
<pre><code class="language-cpp">Patch* p = new Patch[100];
</code></pre>
<p>Das Problem ist nur: Patch erbt von Object und Object braucht im Ctor einen String. Dh ich muss irgendwie die Patches im Array alle eindeutig benennen, zb so: &quot;Patch1&quot;, &quot;Patch2&quot; etc. Wie könnte ich das machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/292165/array-allokieren-und-alle-objekte-benennen</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 03:54:36 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/292165.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 04 Sep 2011 13:11:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Array allokieren und alle Objekte benennen on Sun, 04 Sep 2011 13:11:59 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>ich habe einen Zeiger Patch* p und will nun ein Array von Patches anlegen. z.b. so:</p>
<pre><code class="language-cpp">Patch* p = new Patch[100];
</code></pre>
<p>Das Problem ist nur: Patch erbt von Object und Object braucht im Ctor einen String. Dh ich muss irgendwie die Patches im Array alle eindeutig benennen, zb so: &quot;Patch1&quot;, &quot;Patch2&quot; etc. Wie könnte ich das machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2114669</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2114669</guid><dc:creator><![CDATA[Wutti]]></dc:creator><pubDate>Sun, 04 Sep 2011 13:11:59 GMT</pubDate></item><item><title><![CDATA[Reply to Array allokieren und alle Objekte benennen on Sun, 04 Sep 2011 13:19:26 GMT]]></title><description><![CDATA[<p>Was ist der Sinn? Brauchst du das überhaupt? Ansonsten führe auch einen Konstruktor ein, der ohne Parameter auskommt.</p>
<pre><code class="language-cpp">Object(const std::string&amp; x = &quot;&quot;)
{
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2114673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2114673</guid><dc:creator><![CDATA[ghjghj]]></dc:creator><pubDate>Sun, 04 Sep 2011 13:19:26 GMT</pubDate></item><item><title><![CDATA[Reply to Array allokieren und alle Objekte benennen on Sun, 04 Sep 2011 13:28:58 GMT]]></title><description><![CDATA[<p>Habs jetzt so gelöst:</p>
<pre><code class="language-cpp">Patch::Patch() :
   Object( str(&quot;Patch%i&quot;, numPatches++) ) {	
}
</code></pre>
<p>numPatches ist eine statische Membervariable.</p>
<p>Scheint zu funktionieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2114679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2114679</guid><dc:creator><![CDATA[Wutti]]></dc:creator><pubDate>Sun, 04 Sep 2011 13:28:58 GMT</pubDate></item><item><title><![CDATA[Reply to Array allokieren und alle Objekte benennen on Sun, 04 Sep 2011 14:51:58 GMT]]></title><description><![CDATA[<p>du musst nur aufpassen, wenn du objekte kopierst (oder funktione/ -saufrufe oder container), nicht das dannd ein zähler auch mit erhöht wird und dann hast du am ende 10000 objekte obwohl du nur 100 objekte erstellt hast und wolltest...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2114714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2114714</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Sun, 04 Sep 2011 14:51:58 GMT</pubDate></item></channel></rss>