<?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[switch(...)]]></title><description><![CDATA[<p>Hi</p>
<p>Als ich soeben im Internet ein wenig über &quot;switch(...)&quot; recherchiert habe, ist mir etwas aufgefallen. In verschiedenen Tutorials wird nach dem Rumpf von switch mal ein Semikolon gesetzt und mal wieder weggelassen.<br />
(Siehe:<br />
<a href="http://tutorial.schornboeck.net/switch.htm" rel="nofollow">http://tutorial.schornboeck.net/switch.htm</a><br />
<a href="http://www.volkard.de/vcppkold/switch.html" rel="nofollow">http://www.volkard.de/vcppkold/switch.html</a> )</p>
<pre><code class="language-cpp">int n = 0;

// Variante 1 ohne Semikolon
switch(n){
   case 0:
      break;
}

// Variante 2 mit Semikolon
switch(n){
   case 0:
      break;
};
</code></pre>
<p>Mein Compiler (VS2005) akzeptiert in der Tat beide Varianten.<br />
Nun meine Frage, welche ist &quot;richtiger&quot; und warum sind eigentlich beide möglich?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/183309/switch</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 05:01:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/183309.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Jun 2007 20:35:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to switch(...) on Sun, 03 Jun 2007 20:35:26 GMT]]></title><description><![CDATA[<p>Hi</p>
<p>Als ich soeben im Internet ein wenig über &quot;switch(...)&quot; recherchiert habe, ist mir etwas aufgefallen. In verschiedenen Tutorials wird nach dem Rumpf von switch mal ein Semikolon gesetzt und mal wieder weggelassen.<br />
(Siehe:<br />
<a href="http://tutorial.schornboeck.net/switch.htm" rel="nofollow">http://tutorial.schornboeck.net/switch.htm</a><br />
<a href="http://www.volkard.de/vcppkold/switch.html" rel="nofollow">http://www.volkard.de/vcppkold/switch.html</a> )</p>
<pre><code class="language-cpp">int n = 0;

// Variante 1 ohne Semikolon
switch(n){
   case 0:
      break;
}

// Variante 2 mit Semikolon
switch(n){
   case 0:
      break;
};
</code></pre>
<p>Mein Compiler (VS2005) akzeptiert in der Tat beide Varianten.<br />
Nun meine Frage, welche ist &quot;richtiger&quot; und warum sind eigentlich beide möglich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298078</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298078</guid><dc:creator><![CDATA[asß0d]]></dc:creator><pubDate>Sun, 03 Jun 2007 20:35:26 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Sun, 03 Jun 2007 20:37:32 GMT]]></title><description><![CDATA[<p>Da gehört dein Semikolon hin.</p>
<p>Kompilieren tut das weil ein alleinstehendes Semikolon eine leere Anweisung darstellt und das gültiges C++ ist.</p>
<p>Du kannst z.B. auch <strong>int i = 0;;</strong> schreiben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298084</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298084</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Sun, 03 Jun 2007 20:37:32 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Sun, 03 Jun 2007 21:11:48 GMT]]></title><description><![CDATA[<p>Daraus ergeben sich gleich drei Lektionen (die imho auch wichtig sind)</p>
<p>1. Nur weil ein Compiler etwas compiliert muß das noch lange nicht richtig sein. (imho einer der größten Fehlannahmen die vor allem unter Anfägern weit verbreitet ist)</p>
<p>2. Tutorials sind zwar eine gute Sache und fürs Lernen sehr hilreich, aber sie ersetzen keine Referenzliteratur. (Damit will ich die Arbeit der Leute auf keinen Fall heruntermachen)</p>
<p>3. Wer ernsthaft C++ lernen will kommt früher oder später um _das_ Referenzwerk einfach nicht herum (die C++ programmiersprache von Bjarne Stroustrup). Da steht es z.B. auch richtig drin mit dem Semikolons <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/1298110</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298110</guid><dc:creator><![CDATA[losla]]></dc:creator><pubDate>Sun, 03 Jun 2007 21:11:48 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Sun, 03 Jun 2007 21:19:16 GMT]]></title><description><![CDATA[<p>Danke für die Info. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298113</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298113</guid><dc:creator><![CDATA[asdß0f]]></dc:creator><pubDate>Sun, 03 Jun 2007 21:19:16 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Mon, 04 Jun 2007 09:26:18 GMT]]></title><description><![CDATA[<p>Mag sein, dass es so im Struppi steht, im Standard steht es aber nicht. Somit würde ich sagen, dass das Semikolon da unnötig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298259</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298259</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 04 Jun 2007 09:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Mon, 04 Jun 2007 10:04:55 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Mag sein, dass es so im Struppi steht, im Standard steht es aber nicht. Somit würde ich sagen, dass das Semikolon da unnötig ist.</p>
</blockquote>
<p>Ich glaube es war gemeint, dass im Struppi drinsteht, dass das Semikolon da überflüssig ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298290</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298290</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Mon, 04 Jun 2007 10:04:55 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Mon, 04 Jun 2007 10:40:24 GMT]]></title><description><![CDATA[<p>Wenn das so gemeint war, ist es ja OK.<br />
Ich hatte das hier</p>
<p>lolz schrieb:</p>
<blockquote>
<p>Da gehört dein Semikolon hin....</p>
</blockquote>
<p>halt so interpretiert, dass ein Semikolon erforderlich sei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298321</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298321</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Mon, 04 Jun 2007 10:40:24 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Mon, 04 Jun 2007 10:48:38 GMT]]></title><description><![CDATA[<p>Wird eh wegoptimiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298331</guid><dc:creator><![CDATA[kenner des blödsinns]]></dc:creator><pubDate>Mon, 04 Jun 2007 10:48:38 GMT</pubDate></item><item><title><![CDATA[Reply to switch(...) on Mon, 04 Jun 2007 11:05:26 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Wenn das so gemeint war, ist es ja OK.<br />
Ich hatte das hier</p>
<p>lolz schrieb:</p>
<blockquote>
<p>Da gehört dein Semikolon hin....</p>
</blockquote>
<p>halt so interpretiert, dass ein Semikolon erforderlich sei.</p>
</blockquote>
<p>Da hab ich mich vertippt. Richtig ist natürlich <strong>kein</strong>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1298343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1298343</guid><dc:creator><![CDATA[lolz]]></dc:creator><pubDate>Mon, 04 Jun 2007 11:05:26 GMT</pubDate></item></channel></rss>