<?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[typedef array in function]]></title><description><![CDATA[<pre><code>typedef int IntegerArray[2];

IntegerArray test()
{
    IntegerArray ia;
    ia[0]=123;
    ia[1]=456;
    return ia;
}
</code></pre>
<p>Wieso bekomme ich hier folgende Fehlermeldung ?</p>
<pre><code>.....\Array_zuweissen.cpp|5|error: 'test' declared as function returning an array|
</code></pre>
<p>Folgender Code, ohne Array geht:</p>
<pre><code>typedef int Integer;

Integer abc()
{
    Integer i;
    i=121;
    return i;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/328105/typedef-array-in-function</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 12:02:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/328105.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 22 Sep 2014 19:32:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 19:34:48 GMT]]></title><description><![CDATA[<pre><code>typedef int IntegerArray[2];

IntegerArray test()
{
    IntegerArray ia;
    ia[0]=123;
    ia[1]=456;
    return ia;
}
</code></pre>
<p>Wieso bekomme ich hier folgende Fehlermeldung ?</p>
<pre><code>.....\Array_zuweissen.cpp|5|error: 'test' declared as function returning an array|
</code></pre>
<p>Folgender Code, ohne Array geht:</p>
<pre><code>typedef int Integer;

Integer abc()
{
    Integer i;
    i=121;
    return i;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2418730</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418730</guid><dc:creator><![CDATA[Mathuas]]></dc:creator><pubDate>Mon, 22 Sep 2014 19:34:48 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 19:34:23 GMT]]></title><description><![CDATA[<p>Weil eine Funktion kein Array zurückgeben kann. Verwend <code>std::array</code> oder bau dir selbst ein struct, das dein Array enthält und return dann ein solches... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418731</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 22 Sep 2014 19:34:23 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 19:56:52 GMT]]></title><description><![CDATA[<p>So geht es:</p>
<pre><code>#include &lt;iostream&gt;

struct TMatrix
{
    double matrix[4][4];
};

TMatrix MatrixIdentity()
{
    TMatrix m;
    for(int i = 0; i &lt;= 3; i++)
    {
        for(int j = 0; j &lt;= 3; j++)
        {
            m.matrix[i][j] = 0.0;
            //m.matrix[i,j] = 0.0;
        }
    }

    return m;
}

int main()
{
    TMatrix m;

    m = MatrixIdentity();
    for(int i = 0; i &lt;= 3; i++)
    {
        for(int j = 0; j &lt;= 3; j++)
        {
            //std::cout &lt;&lt; m.matrix[i, j] &lt;&lt; ' ';
            std::cout &lt;&lt; m.matrix[i][j] &lt;&lt; ' ';
        }
    }
    return 0;
}
</code></pre>
<p>Was passiert hier ?</p>
<p>Hier kommt eine Kompilerfehler:</p>
<pre><code>m.matrix[i,j] = 0.0;
</code></pre>
<p>Dies kann er kompilieren, kommen aber anstelle von <strong>0</strong>, irgendwelche Hex-Ziffern.</p>
<pre><code>std::cout &lt;&lt; m.matrix[i, j] &lt;&lt; ' ';
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2418736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418736</guid><dc:creator><![CDATA[Mathuas]]></dc:creator><pubDate>Mon, 22 Sep 2014 19:56:52 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 19:57:48 GMT]]></title><description><![CDATA[<p>Das , ist der Kommaoperator.<br />
Mehrdimensionaler Arrays indizierst du mit [i][j].</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418738</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418738</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 22 Sep 2014 19:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:11:40 GMT]]></title><description><![CDATA[<blockquote>
<p>Das , ist der Kommaoperator.</p>
</blockquote>
<p>Für was wird dieser gebraucht ?</p>
<p>Über sowas bin ich schon mal gestolpert.</p>
<p>Ich wollte</p>
<pre><code>float f=(1.2);
</code></pre>
<p>anstelle</p>
<pre><code>float f=(1,2);
</code></pre>
<p>schreiben.</p>
<p>Da hatte ich lange nach dem Fehler gesucht. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418740</guid><dc:creator><![CDATA[Mathuas]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:11:40 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:14:38 GMT]]></title><description><![CDATA[<p>Mathuas schrieb:</p>
<blockquote>
<blockquote>
<p>Das , ist der Kommaoperator.</p>
</blockquote>
<p>Für was wird dieser gebraucht ?</p>
</blockquote>
<p>Für coole kryptische Sachen.<br />
Und hauptsächlich für for loops:</p>
<pre><code>for (...;...;++i, ++j)
  ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2418741</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418741</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:14:38 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:15:47 GMT]]></title><description><![CDATA[<p>Siehe <a href="http://en.wikipedia.org/wiki/Comma_operator" rel="nofollow">Comma Operator</a>. Das hättest du auch selber googeln können <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418742</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418742</guid><dc:creator><![CDATA[icarus2]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:15:47 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 21:02:40 GMT]]></title><description><![CDATA[<p>Mathuas schrieb:</p>
<blockquote>
<blockquote>
<p>Das , ist der Kommaoperator.</p>
</blockquote>
<p>Für was wird dieser gebraucht ?</p>
</blockquote>
<p>(Eigentlich für gar nichts.)</p>
<p>Naja, manchmal will man zwei Sachen tun, aber sie Sprache verlangt da einen Ausdruck und keine Anweisung.</p>
<pre><code>for( int i=1,j=2 ; j&lt;=100 ; i+=j,j+=2 )
</code></pre>
<p>edit: Auf Arcoths Anreging geändert zu Kubikzahlen.</p>
<pre><code>for( int i=0,j=1,k=1 ; k&lt;=1000 ; i+=6,j+=i,k+=j )
		cout&lt;&lt;k&lt;&lt;'\n';
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2418743</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418743</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 22 Sep 2014 21:02:40 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:36:28 GMT]]></title><description><![CDATA[<p>volkard schrieb:</p>
<blockquote>
<pre><code>for( int i=1,j=2 ; j&lt;=100 ; i+=j,j+=2 )
</code></pre>
</blockquote>
<p>Warum zeigst du so einen Code?<br />
Nicht lustig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418745</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:36:28 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:46:46 GMT]]></title><description><![CDATA[<p>Arcoth schrieb:</p>
<blockquote>
<p>volkard schrieb:</p>
<blockquote>
<pre><code>for( int i=1,j=2 ; j&lt;=100 ; i+=j,j+=2 )
</code></pre>
</blockquote>
<p>Warum zeigst du so einen Code?<br />
Nicht lustig.</p>
</blockquote>
<p>Zur Abschreckung?<br />
Uups, j sollte mit 3 anfangen. Hab ich den Code nicht bei Dir schonmal gesehen? Auf kräftigen Prozessoren (PCs) dürfte MUL für Quadratzahlen schneller sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418748</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418748</guid><dc:creator><![CDATA[volkard]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:46:46 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Mon, 22 Sep 2014 20:49:39 GMT]]></title><description><![CDATA[<blockquote>
<p>Zur Abschreckung?</p>
</blockquote>
<p>Ja, das ist gut. Aber dann auch ein bisschen expliziter machen. Werner zu rate ziehen. Einen Schleifenkopf so hässlich schreiben dass man länger als fünf Sekunden braucht um ihn zu verstehen, die Höchstzeit nämlich.</p>
<blockquote>
<p>Auf kräftigen Prozessoren (PCs) dürfte MUL für Quadratzahlen schneller sein.</p>
</blockquote>
<p>Stimmt, das haben wir bereits gesehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418749</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Mon, 22 Sep 2014 20:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Tue, 23 Sep 2014 16:15:33 GMT]]></title><description><![CDATA[<pre><code>for( int i=1,j=2 ; j&lt;=100 ; i+=j,j+=2
</code></pre>
<p>Da kann ich mir noch eine Sinn vorstellen, aber bei folgenden Beispiele habe ich Fragen:</p>
<pre><code>int b = 10;
    for(int i = 0; i &lt;= 3; i++)
    {
        for(int j = 0; j &lt;= 3; j++)
        {
            std::cout &lt;&lt; m.matrix[i][b += 10, j] &lt;&lt; std::endl;
            std::cout &lt;&lt; b &lt;&lt; std::endl;
        }
    }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2418844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418844</guid><dc:creator><![CDATA[Mathuas]]></dc:creator><pubDate>Tue, 23 Sep 2014 16:15:33 GMT</pubDate></item><item><title><![CDATA[Reply to typedef array in function on Tue, 23 Sep 2014 17:12:20 GMT]]></title><description><![CDATA[<p>Extrem sinnlose Anwendung des Komma-Operators. Es ist praktisch äquivalent zu</p>
<pre><code>std::cout &lt;&lt; m.matrix[i][j] &lt;&lt; std::endl;
            b += 10;
            std::cout &lt;&lt; b &lt;&lt; std::endl;
</code></pre>
<p>Dabei aber natürlich schwerer zu lesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2418850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2418850</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Tue, 23 Sep 2014 17:12:20 GMT</pubDate></item></channel></rss>