<?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[Gültigkeitsbereiche]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich kann mir folgende Frage im Standard nicht klar beantworten:</p>
<pre><code class="language-cpp">void Funktion(int x)
{
  for(int x=0; x &lt; 10; x++) {cout &lt;&lt; &quot;Blah&quot;;}
}
</code></pre>
<p>Ist das nun nach dem Standard erlaubt und definiert, oder nicht?<br />
Ich weiß jedenfalls nicht ob die Deklaration für die for-Schleife in den Schleifenblock zugerechnet wird.</p>
<p>Wurde sicherlich schon einmal durchgenommen, fand aber nichts mittels Suchfunktion.</p>
<p>Vielen Dank für Eure Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/253917/gültigkeitsbereiche</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 11:44:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/253917.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 08 Nov 2009 22:15:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 22:15:02 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich kann mir folgende Frage im Standard nicht klar beantworten:</p>
<pre><code class="language-cpp">void Funktion(int x)
{
  for(int x=0; x &lt; 10; x++) {cout &lt;&lt; &quot;Blah&quot;;}
}
</code></pre>
<p>Ist das nun nach dem Standard erlaubt und definiert, oder nicht?<br />
Ich weiß jedenfalls nicht ob die Deklaration für die for-Schleife in den Schleifenblock zugerechnet wird.</p>
<p>Wurde sicherlich schon einmal durchgenommen, fand aber nichts mittels Suchfunktion.</p>
<p>Vielen Dank für Eure Hilfe!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1805360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805360</guid><dc:creator><![CDATA[sqrt(-1)]]></dc:creator><pubDate>Sun, 08 Nov 2009 22:15:02 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 22:44:53 GMT]]></title><description><![CDATA[<p>Ist definiert. Das äussere x wird vom inneren überdeckt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1805367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805367</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 08 Nov 2009 22:44:53 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 22:47:09 GMT]]></title><description><![CDATA[<p>In 3.3.2:4</p>
<blockquote>
<p>Names declared in the for-init-statement, and in the condition of if, while, for, and switch statements are local to the if, while, for, or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outmost blocks) of the controlled statement; see 6.4.</p>
</blockquote>
<p>Also ist es nicht erlaubt außerhalb des for-init-statement den gleichen Namen zu deklarieren?</p>
<p>Wieso meckert der ICC dann nicht (auch mit /W3)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1805369</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805369</guid><dc:creator><![CDATA[sqrt(-1)]]></dc:creator><pubDate>Sun, 08 Nov 2009 22:47:09 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 22:49:11 GMT]]></title><description><![CDATA[<p>Drakon: Wird da in der zweiten Zeile nicht das Gegenteil behauptet?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1805371</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805371</guid><dc:creator><![CDATA[sqrt(-1)]]></dc:creator><pubDate>Sun, 08 Nov 2009 22:49:11 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 22:59:41 GMT]]></title><description><![CDATA[<p>Hmm. Ich habe nicht nachgeschaut gehabt und bin davon ausgegangen, dass es, wie sonst mit Überdeckung gehandhabt wird..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1805372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805372</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sun, 08 Nov 2009 22:59:41 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 23:24:34 GMT]]></title><description><![CDATA[<p>Das ist anders zu verstehen. Es ist gemeint, das sowas nicht erlaubt ist:</p>
<pre><code class="language-cpp">for(int i=0;i&lt;1;++i)
 {
  int i;
 }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1805381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805381</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sun, 08 Nov 2009 23:24:34 GMT</pubDate></item><item><title><![CDATA[Reply to Gültigkeitsbereiche on Sun, 08 Nov 2009 23:29:29 GMT]]></title><description><![CDATA[<p>sqrt(-1) schrieb:</p>
<blockquote>
<p>In 3.3.2:4</p>
<blockquote>
<p>Names declared in the for-init-statement, and in the condition of if, while, for, and switch statements are local to the if, while, for, or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outmost blocks) of the controlled statement; see 6.4.</p>
</blockquote>
<p>Also ist es nicht erlaubt außerhalb des for-init-statement den gleichen Namen zu deklarieren?</p>
<p>Wieso meckert der ICC dann nicht (auch mit /W3)?</p>
</blockquote>
<p>Es ist vom &quot;controlled statement&quot; die Rede, also dem Statement, auf das sich das if/while/for/switch bezieht, nicht dem Block, innerhalb dessen das for steht.</p>
<pre><code class="language-cpp">void foo(int x)
{
  for(int x=0; x &lt; 10; x++) // ok
  {
      int x; // Fehler
      {
          int x;  // ok
      }
  }
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1805386</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1805386</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sun, 08 Nov 2009 23:29:29 GMT</pubDate></item></channel></rss>