<?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[Anfängerin Rückgabewert array?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe Problem nachzuvollziehen warum ich kein array als Rückgabewert einer funktion in einer klasse definieren kann.</p>
<p>Ich mache folgendes:</p>
<pre><code>class1::method1
{
    Class2 c = Class2();
    double arr[2][2] = c.method2();
}

double arr[][] Class2::method2
{
    double arr[2][2];
    return arr;
}
</code></pre>
<p>Oder wie soll ich das array übergeben?</p>
<p>Danke für eure ratschläge</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/153293/anfängerin-rückgabewert-array</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 07:27:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153293.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Jul 2006 20:58:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Anfängerin Rückgabewert array? on Fri, 14 Jul 2006 20:58:15 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe Problem nachzuvollziehen warum ich kein array als Rückgabewert einer funktion in einer klasse definieren kann.</p>
<p>Ich mache folgendes:</p>
<pre><code>class1::method1
{
    Class2 c = Class2();
    double arr[2][2] = c.method2();
}

double arr[][] Class2::method2
{
    double arr[2][2];
    return arr;
}
</code></pre>
<p>Oder wie soll ich das array übergeben?</p>
<p>Danke für eure ratschläge</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1097969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1097969</guid><dc:creator><![CDATA[Valentina]]></dc:creator><pubDate>Fri, 14 Jul 2006 20:58:15 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerin Rückgabewert array? on Fri, 14 Jul 2006 21:38:44 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>du kannst kein Array undefinierter Größe zurückgeben. Entweder benutzt du Zeiger und legt den Speicher für das Array mit new selber an (und löscht den nach den Gebrauch wieder mit delete), oder du verwendest das dynamische Array <em>std::vector</em>.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1097986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1097986</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Fri, 14 Jul 2006 21:38:44 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerin Rückgabewert array? on Fri, 14 Jul 2006 22:12:22 GMT]]></title><description><![CDATA[<p>ein 2-dimensionales Array zu übergeben ist etwas kompliziert:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

void foo( double **array, size_t dim_x, size_t dim_y )
{
    for( size_t y = 0; y &lt; dim_y; ++y ) {

        for( size_t x = 0; x &lt; dim_x; ++x )

            cout &lt;&lt; array[ x ][ y ] &lt;&lt; &quot;; &quot;;

        cout &lt;&lt; endl;
    }

    cout &lt;&lt; endl;
}

int main( )
{
    double bar[ 2 ][ 2 ] = { { 1.1, 2.2 }, { 3.3, 4.4 } };
    double *p[ 2 ];

    for( size_t i = 0; i &lt; 2; ++i )
        p[ i ] = bar[ i ];

    foo( p, 2, 2 );
}
</code></pre>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1098003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1098003</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Fri, 14 Jul 2006 22:12:22 GMT</pubDate></item><item><title><![CDATA[Reply to Anfängerin Rückgabewert array? on Sat, 15 Jul 2006 13:16:00 GMT]]></title><description><![CDATA[<p>Swordfish schrieb:</p>
<blockquote>
<p>ein 2-dimensionales Array zu übergeben ist etwas kompliziert:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

using namespace std;

void foo( double **array, size_t dim_x, size_t dim_y )
{
    for( size_t y = 0; y &lt; dim_y; ++y ) {
		
        for( size_t x = 0; x &lt; dim_x; ++x )
			
            cout &lt;&lt; array[ x ][ y ] &lt;&lt; &quot;; &quot;;

        cout &lt;&lt; endl;
    }

    cout &lt;&lt; endl;
}

int main( )
{
    double bar[ 2 ][ 2 ] = { { 1.1, 2.2 }, { 3.3, 4.4 } };
    double *p[ 2 ];

    for( size_t i = 0; i &lt; 2; ++i )
        p[ i ] = bar[ i ];
	
    foo( p, 2, 2 );
}
</code></pre>
<p>Greetz, Swordfish</p>
</blockquote>
<p>oder auch</p>
<pre><code class="language-cpp">void foo( double (&amp;array)[2][2]);
// ...
int main( )
{
    double bar[ 2 ][ 2 ] = { { 1.1, 2.2 }, { 3.3, 4.4 } };
    foo( bar );
}
</code></pre>
<p>aber wahrscheinlich ist das zu simpel.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1098207</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1098207</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 15 Jul 2006 13:16:00 GMT</pubDate></item></channel></rss>