<?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[Arrays erstellen, so daß Constructor greift]]></title><description><![CDATA[<p>Hallo,</p>
<p>der Titel läßt schon vermuten, daß ich nicht genau weiß, wie ich das Problem beschreiben soll. Ist aber eigentlich recht einfach:</p>
<pre><code>IntArray v(7);  // erstellt ein Integer Array der Größe 7
IntArray v[10]; // erstellt ein Array mit 10 Einträgen mit jeweils einem IntArray (Größe 0)
</code></pre>
<p>Meine Frage ist, wie ich beides verbinden kann. Sprich: Ich möchte eine Array mit 10 Einträgen erstellen, in dem in jedem Eintrag ein IntArray der Größe 7 steht. Geht das überhaupt?</p>
<p>Vielen Dank für jede Hilfe! <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>Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/124261/arrays-erstellen-so-daß-constructor-greift</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 13:27:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/124261.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Oct 2005 06:20:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 06:20:28 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>der Titel läßt schon vermuten, daß ich nicht genau weiß, wie ich das Problem beschreiben soll. Ist aber eigentlich recht einfach:</p>
<pre><code>IntArray v(7);  // erstellt ein Integer Array der Größe 7
IntArray v[10]; // erstellt ein Array mit 10 Einträgen mit jeweils einem IntArray (Größe 0)
</code></pre>
<p>Meine Frage ist, wie ich beides verbinden kann. Sprich: Ich möchte eine Array mit 10 Einträgen erstellen, in dem in jedem Eintrag ein IntArray der Größe 7 steht. Geht das überhaupt?</p>
<p>Vielen Dank für jede Hilfe! <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>Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900832</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 26 Oct 2005 06:20:28 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 06:37:24 GMT]]></title><description><![CDATA[<p>Seit wann hat C Konstruktoren? (bzw das Problem sollte eine Etage tiefer hingehören :))</p>
<p>Du kannst bei einem Array auch eine Initialisierungsliste angeben:</p>
<pre><code class="language-cpp">IntArray v[10] = {IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7),IntArray(7)};
</code></pre>
<p>Oder alternativ definierst du eine resize()-Methode für dein Array, die die Größe nachträglich anpasst:</p>
<pre><code class="language-cpp">InArray v[10];
for(int i=0;i&lt;10;++i) v[i].resize(7);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/900843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900843</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 26 Oct 2005 06:37:24 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 09:00:03 GMT]]></title><description><![CDATA[<p>Oh Mist, hab mich so auf das Array versteift, daß ich im falschen Forum gelandet bin. *peinlich sei* Ein Mod möge es bitte verschieben, wenn nötig...</p>
<p>Die Initialisierung würde zwar gehen, aber das Beispiel mit 10 Einträgen ist auch etwas klein... Ich habe so ca. 5000 Einträge, deren Anzahl auch variert. (Ich würde das ganze dann natürlich mit nem Pointer auf das Array machen.)</p>
<p>Die zweite Möglichkeit nutze ich derzeit auch tatsächlich. Ich hatte gehofft, es geht etwa schneller bzw. komfortabler.</p>
<p>Danke &amp; Gruß, Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/900926</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900926</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 26 Oct 2005 09:00:03 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 09:14:39 GMT]]></title><description><![CDATA[<p>Du kannst auch statt eines simplen Arrays einen STL-Container verwenden, da geht das einfacher:</p>
<pre><code class="language-cpp">#include &lt;vector&gt;

std::vector v(10,IntArray(7));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/900941</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/900941</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 26 Oct 2005 09:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 11:06:57 GMT]]></title><description><![CDATA[<p>Das Beispiel ist nicht auf Integer Arrays beschränkt. So habe ich zum Beispiel auch ein VectorArray, in dem dreidimensionale Vektoren zu finden sind.</p>
<p>Ich hätte dann quasi ein Array, was ähnlich wie double *[3][Anzahl_Vektoren][Anzahl_Arrays] aufgebaut... Ich hätt's nur gern komfortabler. *g*</p>
<p>Gruß, Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/901060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901060</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 26 Oct 2005 11:06:57 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 26 Oct 2005 11:31:55 GMT]]></title><description><![CDATA[<p>Du kannst auch die STL-Container ineinander verschachteln, das dürfte etwa so aussehen:</p>
<pre><code class="language-cpp">vector&lt;vector&lt;vector&lt;double&gt; &gt; &gt; ultimate_array(10,vector&lt;vector&lt;double&gt; &gt;(5,vector&lt;double&gt;(7,3.14)));
</code></pre>
<p>Aber vermutlich ist es besser, du schachtelst dir die ganze Funktionalität in einer eigenen Klasse, die einen entsprechenden Konstruktor bekommt, z.B.:</p>
<pre><code class="language-cpp">class my_3d_array{
  // erstellt das Array mit sx*sy*sz Elementen und initialisiert alle mit val:
  my_3d_array(double val,int sx,int sy,int sz);

  //...
};

my_3d_array(3.14,10,5,7);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/901069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/901069</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 26 Oct 2005 11:31:55 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Mon, 02 Jan 2006 13:44:52 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=13512" rel="nofollow">c.rackwitz</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=10" rel="nofollow">ANSI C</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/954756</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/954756</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Mon, 02 Jan 2006 13:44:52 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Mon, 02 Jan 2006 14:00:05 GMT]]></title><description><![CDATA[<p>Dee schrieb:</p>
<blockquote>
<p>Hallo,</p>
<p>der Titel läßt schon vermuten, daß ich nicht genau weiß, wie ich das Problem beschreiben soll. Ist aber eigentlich recht einfach:</p>
<pre><code>IntArray v(7);  // erstellt ein Integer Array der Größe 7
IntArray v[10]; // erstellt ein Array mit 10 Einträgen mit jeweils einem IntArray (Größe 0)
</code></pre>
<p>Meine Frage ist, wie ich beides verbinden kann. Sprich: Ich möchte eine Array mit 10 Einträgen erstellen, in dem in jedem Eintrag ein IntArray der Größe 7 steht. Geht das überhaupt?</p>
<p>Vielen Dank für jede Hilfe! <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>Dee</p>
</blockquote>
<pre><code class="language-cpp">IntArray v[10][7];
</code></pre>
<p>oder ausführlicher</p>
<pre><code class="language-cpp">typedef IntArray Elem[7];
Elem v[10];
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/954776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/954776</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 02 Jan 2006 14:00:05 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 13:14:35 GMT]]></title><description><![CDATA[<p>Hallo Camper...</p>
<p>Mit</p>
<pre><code>IntArray v[10][7];
</code></pre>
<p>erhalte ich nur eine 10x7-&quot;Matrix&quot; mit IntArrays (also 70 Stück), deren Größe aber überall 0 ist. Das gleiche erreicht man mit der Typedef-Definition. Und das will ich ja gerade nicht... Ich hätte gern n IntArrays, welche alle die Größe m haben, welche nur durch einen Konstruktoraufruf</p>
<pre><code>IntArray(m);
</code></pre>
<p>erreicht werden kann.</p>
<p>Gruß, Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975888</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 25 Jan 2006 13:14:35 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 13:17:59 GMT]]></title><description><![CDATA[<p>Arrays haben keinen eigenen Konstruktor, du könntest dort aber eine Initialisierungsliste mit übergeben:</p>
<pre><code class="language-cpp">IntArray v[10][7] =
{
  {m,m,m,m,m,m,m},
  {m,m,m,m,m,m,m},
  ...
};
</code></pre>
<p>Alternativ verwendest du statt eines Arrays einen STL-Container (z.B. vector) oder eine selbstgeschriebene Array-Klasse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975897</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975897</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Wed, 25 Jan 2006 13:17:59 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 13:43:00 GMT]]></title><description><![CDATA[<p>Äh, die IntArray-Klasse ist ja selbst geschrieben... Ich dachte, das wäre klar. <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>Daher ja meine Frage, ob man Allokierung und Initalisierung zusammen machen kann.</p>
<p>Gruß, Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975952</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975952</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 25 Jan 2006 13:43:00 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 13:48:45 GMT]]></title><description><![CDATA[<p>Ja, kannst du, aber nicht mit plumpen C-Arrays. Um ein ganzes Paket von IntArray's auf einmal anzulegen und zu initialisieren, benötigst du ein IAArray:</p>
<pre><code class="language-cpp">class IAArray
{
public:
  IAArray(int count,int size) : fields(new IntArray[count])
  {
    for(int i=0;i&lt;count;++i) fields[i].resize(size);
  }
  ~IAArray() { delete[] fields;}
private:
  IntArray* fields;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/975966</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975966</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Wed, 25 Jan 2006 13:48:45 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 14:27:37 GMT]]></title><description><![CDATA[<p>Also doch ne neue Klasse dafür. Okay, danke, dann weiß ich bescheid...</p>
<p>Gruß, Dee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976007</guid><dc:creator><![CDATA[Dee]]></dc:creator><pubDate>Wed, 25 Jan 2006 14:27:37 GMT</pubDate></item><item><title><![CDATA[Reply to Arrays erstellen, so daß Constructor greift on Wed, 25 Jan 2006 14:30:06 GMT]]></title><description><![CDATA[<p>Das sagte ich doch bereits (falls du zu faul bist, selber eine zu schreiben, nimm einen STL-Container dafür ;))</p>
]]></description><link>https://www.c-plusplus.net/forum/post/976012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/976012</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 25 Jan 2006 14:30:06 GMT</pubDate></item></channel></rss>