<?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[Unterschied i++ &amp;amp; ++i]]></title><description><![CDATA[<p>Ich hab hier mal ein kleines Beispiel programmiert, dass mir ohne Hilfe den Unterschied erklären sollte jedoch bleibt es gleich... was hab ich falsch gemacht oder was bedeutet das genau?</p>
<p>PS: Warum bleibt es auf 1 stehen wenn ich das static weglasse ?</p>
<pre><code>#include &lt;iostream&gt;

void InkrementVor()
{
	static int i1 = 0;
	++i1;
	std::cout &lt;&lt; i1 &lt;&lt; std::endl;
}

void InkrementNach()
{
	static int i2 = 0;
	i2++;
	std::cout &lt;&lt; i2 &lt;&lt; std::endl;
}

int main()
{
	InkrementVor();
	InkrementVor();
	InkrementVor();
	InkrementVor();
	InkrementVor();
	std::cout &lt;&lt; &quot;-------------&quot; &lt;&lt; std::endl;
	InkrementNach();
	InkrementNach();
	InkrementNach();
	InkrementNach();
	InkrementNach();

	system(&quot;PAUSE&quot;);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/332092/unterschied-i-amp-i</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 18:48:17 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/332092.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 08 Apr 2015 21:58:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unterschied i++ &amp;amp; ++i on Wed, 08 Apr 2015 22:00:09 GMT]]></title><description><![CDATA[<p>Ich hab hier mal ein kleines Beispiel programmiert, dass mir ohne Hilfe den Unterschied erklären sollte jedoch bleibt es gleich... was hab ich falsch gemacht oder was bedeutet das genau?</p>
<p>PS: Warum bleibt es auf 1 stehen wenn ich das static weglasse ?</p>
<pre><code>#include &lt;iostream&gt;

void InkrementVor()
{
	static int i1 = 0;
	++i1;
	std::cout &lt;&lt; i1 &lt;&lt; std::endl;
}

void InkrementNach()
{
	static int i2 = 0;
	i2++;
	std::cout &lt;&lt; i2 &lt;&lt; std::endl;
}

int main()
{
	InkrementVor();
	InkrementVor();
	InkrementVor();
	InkrementVor();
	InkrementVor();
	std::cout &lt;&lt; &quot;-------------&quot; &lt;&lt; std::endl;
	InkrementNach();
	InkrementNach();
	InkrementNach();
	InkrementNach();
	InkrementNach();

	system(&quot;PAUSE&quot;);
	return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2449538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2449538</guid><dc:creator><![CDATA[crazyyzarc]]></dc:creator><pubDate>Wed, 08 Apr 2015 22:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to Unterschied i++ &amp;amp; ++i on Wed, 08 Apr 2015 22:37:06 GMT]]></title><description><![CDATA[<pre><code>int i1 = 1;
int i2 = 1;
cout &lt;&lt; &quot;Vor Präinkrement: &quot; &lt;&lt; i1 &lt;&lt; &quot;\nVor Postinkrement: &quot; &lt;&lt; i2;
cout &lt;&lt; &quot;\n\&quot;Während\&quot; Präinkrement: &quot; &lt;&lt; ++i1 &lt;&lt; &quot;\n\&quot;Während\&quot; Postinkrement: &quot; &lt;&lt; i2++;
cout &lt;&lt; &quot;\nNach Präinkrement: &quot; &lt;&lt; i1 &lt;&lt; &quot;\nNach Postinkrement: &quot; &lt;&lt; i2;
</code></pre>
<p>Damit klarer?</p>
<p>Wobei das &quot;Während&quot; hier bewusst in Anführungsstriche gesetzt ist. Zum Zeitpunkt der Ausgabe ist das Inkrement längst erfolgt, der Unterschied liegt im Rückgabewert der beiden unterschiedlichen Inkrementoperatoren.</p>
<blockquote>
<p>PS: Warum bleibt es auf 1 stehen wenn ich das static weglasse ?</p>
</blockquote>
<p>Weil du dann jeweils auf brandneuen Variablen arbeitest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2449543</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2449543</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 08 Apr 2015 22:37:06 GMT</pubDate></item></channel></rss>