<?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[Prob mit Meldung]]></title><description><![CDATA[<p>!Case bypasses initialization of al local variable</p>
<p>Könnt ihr mir sagen was er damit meint?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/250808/prob-mit-meldung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 20:52:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/250808.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 Sep 2009 14:46:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 14:46:55 GMT]]></title><description><![CDATA[<p>!Case bypasses initialization of al local variable</p>
<p>Könnt ihr mir sagen was er damit meint?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783649</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783649</guid><dc:creator><![CDATA[Revils]]></dc:creator><pubDate>Thu, 24 Sep 2009 14:46:55 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 14:47:50 GMT]]></title><description><![CDATA[<p>Revils schrieb:</p>
<blockquote>
<p>!Case bypasses initialization of al local variable</p>
</blockquote>
<p>Ein case überspringt die initialisierung einer lokalen variablen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783650</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 24 Sep 2009 14:47:50 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 14:50:28 GMT]]></title><description><![CDATA[<p>Man muss den Block einklammern, wenn man Variablen nach einer case-Marke deklariert:</p>
<pre><code class="language-cpp">case 0:
{
int num = 0;
break;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1783652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783652</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Thu, 24 Sep 2009 14:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 14:52:28 GMT]]></title><description><![CDATA[<p>Ey Leute...danke euch. Perfekt. Hat geklappt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783654</guid><dc:creator><![CDATA[Revils]]></dc:creator><pubDate>Thu, 24 Sep 2009 14:52:28 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 14:56:08 GMT]]></title><description><![CDATA[<p>Wenn du unbedingt lokale Variablen innerhalb von <code>switch</code> möchtest, rät es sich, neue Blöcke zu erzeugen. Vergiss das <code>break</code> aber dennoch nicht. Zum Beispiel so, Formatierung ist ja egal:</p>
<pre><code class="language-cpp">switch (Var)
{
    case 1:
    {
        double d = 32.5476;
        d *= 54.7632
    }   break;

    case 2:
    {
        double d = 21.12;
    }   break;
}
</code></pre>
<p>Allerdings solltest du überlegen, ob sich bei lokalen Deklarationen nicht die Auslagerung in eine separate Funktion lohnt. Oft - nicht immer - gehen mit neuen Variablen auch einige Anweisungen einher, die den Code schnell aufblähen und die Funktion lang und unübersichtlich machen. Bei <code>switch</code> selbst kann man sich überlegen, ob nicht Alternativen wie <code>std::map</code> angebracht sind.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783658</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 24 Sep 2009 14:56:08 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 15:19:29 GMT]]></title><description><![CDATA[<p>Für was steht das std::map? Ich muss sagen, ich habe noch nie mit map's gearbeitet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783661</guid><dc:creator><![CDATA[Revils]]></dc:creator><pubDate>Thu, 24 Sep 2009 15:19:29 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 15:17:03 GMT]]></title><description><![CDATA[<p>std::map ist ein Klassen Template: <a href="http://www.cplusplus.com/reference/stl/map/" rel="nofollow">http://www.cplusplus.com/reference/stl/map/</a></p>
<p>Edit: typo korrigiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783673</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 24 Sep 2009 15:17:03 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 15:17:05 GMT]]></title><description><![CDATA[<p>std ist ein namespace, map eine klasse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783674</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783674</guid><dc:creator><![CDATA[kujiopo]]></dc:creator><pubDate>Thu, 24 Sep 2009 15:17:05 GMT</pubDate></item><item><title><![CDATA[Reply to Prob mit Meldung on Thu, 24 Sep 2009 15:48:15 GMT]]></title><description><![CDATA[<p>Naja, statt</p>
<pre><code class="language-cpp">std::string Name;
int Var = ...;
switch (Var)
{
    case 3:
        Name = &quot;der dritte&quot;;
        break;

    case 17:
        Name = &quot;Nummer Siebzehn&quot;;
        break;

    case 42:
        Name = &quot;Die Antwort persönlich&quot;;
        break;
}
</code></pre>
<p>hast du dann sowas:</p>
<pre><code class="language-cpp">std::map&lt;int, std::string&gt; Map;
Map[3] = &quot;der dritte&quot;;
Map[17] = &quot;Nummer Siebzehn&quot;;
Map[42] = &quot;Die Antwort persönlich&quot;;

int Var = ...;
std::string Name = Map[Var]; // Vorsicht, evtl. Eintrag hinzugefügt -&gt; je nachdem find() besser
</code></pre>
<p>Vorteil ist, dass du nicht auf integrale Konstanten als Key-Typen beschränkt bist, sondern irgendwas verwenden kannst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1783705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1783705</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Thu, 24 Sep 2009 15:48:15 GMT</pubDate></item></channel></rss>