<?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[double Array zurückgeben | TypeCast problem]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>bin ziemlich frisch in der C++ Welt und stehe gerade vor einem Problem, wo ich nicht weiter weis. Ich will einfach ein paar Werte in ein Array einlesen und wieder ausgeben. Hier der Code:</p>
<pre><code class="language-cpp">double QuadMatrix::getArray()
{
	for(int i=0; i&lt;getDimension(); i++)
	{
		cout &lt;&lt; &quot;|&quot;;
		for(int j=0; j&lt;getDimension(); j++)
		{
			cout &lt;&lt; &quot;  &quot; &lt;&lt; array[i][j] ;
		}
		cout &lt;&lt; &quot;  |&quot; &lt;&lt; endl;
	}

	return matrix; //FEHLER !? Weiß aber nicht warum  :confused: 
        //return (double)matrix; // gleicher Fehler
}
</code></pre>
<p>Fehler:<br />
error C2440: 'return' : 'double [3][3]' kann nicht in 'double' konvertiert werden</p>
<p>Meine Klasse sieht so aus:</p>
<pre><code class="language-cpp">class
{
private: 
   int dim;
   double array[3][3];
public:
   double getArray();
   void setArray();
}
</code></pre>
<p>Hoffe einer von euch sieht den Fehler. Danke schonmal.</p>
<p>Gruß<br />
Manda</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/255967/double-array-zurückgeben-typecast-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 19:59:07 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/255967.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 06 Dec 2009 12:50:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 12:50:04 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>bin ziemlich frisch in der C++ Welt und stehe gerade vor einem Problem, wo ich nicht weiter weis. Ich will einfach ein paar Werte in ein Array einlesen und wieder ausgeben. Hier der Code:</p>
<pre><code class="language-cpp">double QuadMatrix::getArray()
{
	for(int i=0; i&lt;getDimension(); i++)
	{
		cout &lt;&lt; &quot;|&quot;;
		for(int j=0; j&lt;getDimension(); j++)
		{
			cout &lt;&lt; &quot;  &quot; &lt;&lt; array[i][j] ;
		}
		cout &lt;&lt; &quot;  |&quot; &lt;&lt; endl;
	}

	return matrix; //FEHLER !? Weiß aber nicht warum  :confused: 
        //return (double)matrix; // gleicher Fehler
}
</code></pre>
<p>Fehler:<br />
error C2440: 'return' : 'double [3][3]' kann nicht in 'double' konvertiert werden</p>
<p>Meine Klasse sieht so aus:</p>
<pre><code class="language-cpp">class
{
private: 
   int dim;
   double array[3][3];
public:
   double getArray();
   void setArray();
}
</code></pre>
<p>Hoffe einer von euch sieht den Fehler. Danke schonmal.</p>
<p>Gruß<br />
Manda</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818592</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818592</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 12:50:04 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 12:57:36 GMT]]></title><description><![CDATA[<p>Was um alles in der Welt returnst du da??</p>
<p>Die Variable matrix existiert ja gar nicht oO</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818594</guid><dc:creator><![CDATA[ExistiertNicht]]></dc:creator><pubDate>Sun, 06 Dec 2009 12:57:36 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 12:58:41 GMT]]></title><description><![CDATA[<p>Das ist doch eine sehr eindeutige Fehlermeldung.<br />
matrix (wo ist das deklariert? sieht man in dem geposteten code nicht) ist vom Typ double [3][3].<br />
Der Rückgabewert der Methode QuadMatrix::getArray() ist double.<br />
double [3][3] kann nicht in double konvertiert werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818595</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818595</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sun, 06 Dec 2009 12:58:41 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:01:08 GMT]]></title><description><![CDATA[<p>Sorry, (copy&amp;paste) Fehler.<br />
Die Variable heist array!<br />
So etwa:</p>
<pre><code class="language-cpp">double QuadMatrix::getArray()
{
    for(int i=0; i&lt;getDimension(); i++)
    {
        cout &lt;&lt; &quot;|&quot;;
        for(int j=0; j&lt;getDimension(); j++)
        {
            cout &lt;&lt; &quot;  &quot; &lt;&lt; array[i][j] ;
        }
        cout &lt;&lt; &quot;  |&quot; &lt;&lt; endl;
    }

    return array; //FEHLER !? Weiß aber nicht warum  :confused:
        //return (double)matrix; // gleicher Fehler
}
</code></pre>
<p>Mit int als Typ geht es aber.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818597</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:01:08 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:04:03 GMT]]></title><description><![CDATA[<p>Deine Matrix besteht aus einem zweidimensionalen Feld von doubles. Die Funktion gibt aber nur genau ein double zurück. Der Rückgabewert deiner Funktion passt also nicht.</p>
<p>Die Konvertierung in int macht ganz sicher nicht das, was du willst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818599</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:04:03 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:06:31 GMT]]></title><description><![CDATA[<p>Das mit &quot;int&quot; meinte ich, wenn ich das array vom Typ int habe und die Funktion auch als return Wert &quot;int&quot; nehme, dann funktioniert es.<br />
Er macht irgendwie beim double Probleme.</p>
<p>So etwa: int array[3][3];<br />
Funktion: int QuadMatrix::getMatrix() { ... return (int)array; }</p>
<p>Dann scheints zu gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818602</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:06:31 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:09:14 GMT]]></title><description><![CDATA[<p>MandaJohn schrieb:</p>
<blockquote>
<p>Mit int als Typ geht es aber.</p>
</blockquote>
<p>Dann gibts du eine Adresse zurück. Ich glaube nicht, dass du es das ist was du möchtest. Weisst du überhaupt was du zurückgeben möchtest?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818605</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818605</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:14:25 GMT]]></title><description><![CDATA[<p>Ich möchte jetzt einfach nur das array mit double Werte füllen und wieder zurückgeben. Deswegen hatte ich return Typ double genommen.<br />
Nur stecke ich gerade genau an dem Punkt. Es ist nur zum Üben gedacht.</p>
<p>Hast du sonst eine Idee, wie ich ein double array zurückgeben kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818610</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818610</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:14:25 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:16:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">double** QuadMatrix::getArray()
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1818612</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818612</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:16:52 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:24:19 GMT]]></title><description><![CDATA[<p>Du tust dich anscheinend schwer mit Arrays als Rückgabewert und das ist auch nicht verwunderlich, da die Übergabe von Arrays in C anders funktioniert als die von anderen Typen. Wenn du eine anfängerfreundlichere Variante suchst, solltest du dir mal die STL-Container angucken, beispielsweise std::vector. Da läuft die Übergabe von Werten genauso wie man es intuitiv erwartet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818613</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818613</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:24:19 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:26:28 GMT]]></title><description><![CDATA[<p>Ok, danke erstmal. Ich probiers mal.</p>
<p>Gruß<br />
Manda</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818614</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818614</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:26:28 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:38:10 GMT]]></title><description><![CDATA[<p>Und verwende keine C-Casts wie</p>
<pre><code class="language-cpp">(int) array
</code></pre>
<p>, solange du nicht genau weisst, was du tust! (und das weisst du nicht). Verwende stattdessen <code>static_cast</code> , das wird dich vor vielen Fehlern bewahren. Hier wäre es zum Beispiel nicht möglich gewesen, einfach eine stille Konvertierung in die Adresse vorzunehmen.</p>
<pre><code class="language-cpp">static_cast&lt;int&gt;(array) // Compilerfehler
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1818620</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818620</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:38:10 GMT</pubDate></item><item><title><![CDATA[Reply to double Array zurückgeben | TypeCast problem on Sun, 06 Dec 2009 13:42:36 GMT]]></title><description><![CDATA[<p>Ok, werd in Zukunft drauf achten.<br />
Danke dir.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1818622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1818622</guid><dc:creator><![CDATA[MandaJohn]]></dc:creator><pubDate>Sun, 06 Dec 2009 13:42:36 GMT</pubDate></item></channel></rss>