<?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[Dynamisches Multi-Array global verwenden]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich stehe vor einem Problem, welches ich aktuell einfach nicht lösen kann.</p>
<p>Ich habe folgende Klasse definiert</p>
<pre><code>class Matrix
{
public: 

struct Matrixeintrag{
int A;
int B;
}

Matrix(const int id, int row, int col);
~Matrix()

int getEintrag(int row, int col)
}
</code></pre>
<p>Funktionen:</p>
<pre><code>Matrix::(const int id, int row, int col)
{
boost::multi_array&lt;Matrixeintrag,2&gt; ErstellteMatrix(boost::extents[row][col]);
}

Matrix::getEintrag(int row, int col)
{
 // Hier soll multi array ausgelesen werden
}
</code></pre>
<p>int main()</p>
<pre><code>Matrix* neueMatrix=new Matrix(5,4)
WertABFRAGE  = neueMatrix-&gt;getEintrag(1,3); // Pseudo
</code></pre>
<p>Mein Problem: Wie stelle ich die ErstellteMatrix, dessen größe in der Laufzeit festgelegt wird für andere Funktionen, wie z.B. getEintrag in einer Klasse zur Verfügung? Da das multi_Array lokal definiert wurde ist der Zugriff darauf nicht möglich. Eine globale Hilfsvariable wiederrum wäre nicht in der Lage dynamisch dieselbe größe zu erhalten.</p>
<p>Diverse Pointerversuche habe ich hinter mir und im boost reference finde ich dazu leider nichts. Auf boost bin ich leider aus div. Gründen angewiesen.</p>
<p>Viele Grüße und vielen Dank für jeden Hinweis</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/339318/dynamisches-multi-array-global-verwenden</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 05:56:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/339318.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 Aug 2016 12:51:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sat, 20 Aug 2016 12:51:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich stehe vor einem Problem, welches ich aktuell einfach nicht lösen kann.</p>
<p>Ich habe folgende Klasse definiert</p>
<pre><code>class Matrix
{
public: 

struct Matrixeintrag{
int A;
int B;
}

Matrix(const int id, int row, int col);
~Matrix()

int getEintrag(int row, int col)
}
</code></pre>
<p>Funktionen:</p>
<pre><code>Matrix::(const int id, int row, int col)
{
boost::multi_array&lt;Matrixeintrag,2&gt; ErstellteMatrix(boost::extents[row][col]);
}

Matrix::getEintrag(int row, int col)
{
 // Hier soll multi array ausgelesen werden
}
</code></pre>
<p>int main()</p>
<pre><code>Matrix* neueMatrix=new Matrix(5,4)
WertABFRAGE  = neueMatrix-&gt;getEintrag(1,3); // Pseudo
</code></pre>
<p>Mein Problem: Wie stelle ich die ErstellteMatrix, dessen größe in der Laufzeit festgelegt wird für andere Funktionen, wie z.B. getEintrag in einer Klasse zur Verfügung? Da das multi_Array lokal definiert wurde ist der Zugriff darauf nicht möglich. Eine globale Hilfsvariable wiederrum wäre nicht in der Lage dynamisch dieselbe größe zu erhalten.</p>
<p>Diverse Pointerversuche habe ich hinter mir und im boost reference finde ich dazu leider nichts. Auf boost bin ich leider aus div. Gründen angewiesen.</p>
<p>Viele Grüße und vielen Dank für jeden Hinweis</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2506037</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506037</guid><dc:creator><![CDATA[g2033]]></dc:creator><pubDate>Sat, 20 Aug 2016 12:51:53 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sat, 20 Aug 2016 13:39:12 GMT]]></title><description><![CDATA[<p>Mach es doch einen Member der Matrixklasse. Wozu ist die Klasse sonst da?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2506041</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506041</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 20 Aug 2016 13:39:12 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sat, 20 Aug 2016 14:02:41 GMT]]></title><description><![CDATA[<p>Die Größe der Matrix muss doch aber bei Aufruf des Konstruktors festgelegt werden. Wie also als Variable irgendwo ablegen, wenn die Größe vor Aufruf des Konstruktors unbekannt ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2506045</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506045</guid><dc:creator><![CDATA[g2033]]></dc:creator><pubDate>Sat, 20 Aug 2016 14:02:41 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sat, 20 Aug 2016 14:59:10 GMT]]></title><description><![CDATA[<p>Fehlt dir das Stichwort Initialisierungsliste?</p>
<pre><code class="language-cpp">class Matrix
{
  boost::multi_array&lt;Matrixeintrag,2&gt; matrix;

  // ...
};

Matrix::Matrix(const int id, int row, int col)
    : matrix(boost::extents[row][col]) // &lt;- Initialisierungsliste
{
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2506052</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506052</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 20 Aug 2016 14:59:10 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sun, 21 Aug 2016 09:42:39 GMT]]></title><description><![CDATA[<p>Th69 schrieb:</p>
<blockquote>
<p>Fehlt dir das Stichwort Initialisierungsliste?</p>
<pre><code class="language-cpp">class Matrix
{
  boost::multi_array&lt;Matrixeintrag,2&gt; matrix;

  // ...
};

Matrix::Matrix(const int id, int row, int col)
    : matrix(boost::extents[row][col]) // &lt;- Initialisierungsliste
{
}
</code></pre>
</blockquote>
<p>Diese Variante erzeugt bei mir den Fehler: &quot;matrix ist kein nicht statischer Datenmember bzw. nicht statische Basisklasse von...&quot;...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2506100</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506100</guid><dc:creator><![CDATA[g2033]]></dc:creator><pubDate>Sun, 21 Aug 2016 09:42:39 GMT</pubDate></item><item><title><![CDATA[Reply to Dynamisches Multi-Array global verwenden on Sun, 21 Aug 2016 09:57:38 GMT]]></title><description><![CDATA[<p>g2033 schrieb:</p>
<blockquote>
<p>Th69 schrieb:</p>
<blockquote>
<p>Fehlt dir das Stichwort Initialisierungsliste?</p>
<pre><code class="language-cpp">class Matrix
{
  boost::multi_array&lt;Matrixeintrag,2&gt; matrix;

  // ...
};

Matrix::Matrix(const int id, int row, int col)
    : matrix(boost::extents[row][col]) // &lt;- Initialisierungsliste
{
}
</code></pre>
</blockquote>
<p>Diese Variante erzeugt bei mir den Fehler: &quot;matrix ist kein nicht statischer Datenmember bzw. nicht statische Basisklasse von...&quot;...</p>
</blockquote>
<p>Fehler selbst gefunden, hatte die Zuweisung von Standardparametern in der Header vergessen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2506102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2506102</guid><dc:creator><![CDATA[gNano]]></dc:creator><pubDate>Sun, 21 Aug 2016 09:57:38 GMT</pubDate></item></channel></rss>