<?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[enums enum::type oder type]]></title><description><![CDATA[<p>Ich habe folgende Frage.<br />
Ich arbeite mit einem Freund an einem Projekt und jetzt kam folgendes Problem auf:<br />
Er benutzt VSC++ und kann den Aufruf enum::typ (also zum beispiel RECHENZEICHEN::PLUS) fehlerfrei compileren, bei einer switch case Anweisung zum Beispiel, ich hingegen bekomme einen Haufen Errors von Netbeans (gcc) wenn ich das compilieren will.<br />
Wieso ist dem so, und was ist jetzt richtiger?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/275172/enums-enum-type-oder-type</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 06:16:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/275172.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Oct 2010 20:24:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 20:24:12 GMT]]></title><description><![CDATA[<p>Ich habe folgende Frage.<br />
Ich arbeite mit einem Freund an einem Projekt und jetzt kam folgendes Problem auf:<br />
Er benutzt VSC++ und kann den Aufruf enum::typ (also zum beispiel RECHENZEICHEN::PLUS) fehlerfrei compileren, bei einer switch case Anweisung zum Beispiel, ich hingegen bekomme einen Haufen Errors von Netbeans (gcc) wenn ich das compilieren will.<br />
Wieso ist dem so, und was ist jetzt richtiger?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963634</guid><dc:creator><![CDATA[Jud4s]]></dc:creator><pubDate>Sun, 10 Oct 2010 20:24:12 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 20:27:59 GMT]]></title><description><![CDATA[<p>Weil MSVC++ diesbezüglich eine Erweiterung anbietet. Im höchsten Warnlevel würde er auch eine Meldung ausgeben.</p>
<p>** <code>Enum::Konstante</code> ist nicht standardkonform**, wird es meines Wissens aber in C++0x sein. Nimm Namensräume, wenn du die Konstanten gliedern willst.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963635</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 10 Oct 2010 20:27:59 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 21:07:07 GMT]]></title><description><![CDATA[<p>Ich verwende dafür gerne folgende Struktur:</p>
<pre><code>namespace MyEnum
{
    enum Id {
      First,
      Second, 
      Last
    };
}
</code></pre>
<p>So kann man schön schreiben:</p>
<pre><code class="language-cpp">void foo(MyEnum::Id id);
MyEnum::Id id = MyEnum::Second;
</code></pre>
<p>Mit C++0x kann man dann natürlich den namespace weglassen und es gleich richtig machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963641</guid><dc:creator><![CDATA[enum]]></dc:creator><pubDate>Sun, 10 Oct 2010 21:07:07 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 22:14:09 GMT]]></title><description><![CDATA[<p>enum schrieb:</p>
<blockquote>
<p>Ich verwende dafür gerne folgende Struktur:</p>
<pre><code>namespace MyEnum
{
    enum Id {
      First,
      Second, 
      Last
    };
}
</code></pre>
</blockquote>
<p>Gibt es ein Argument gegen <code>struct</code> statt <code>namespace</code> ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963648</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Sun, 10 Oct 2010 22:14:09 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 22:27:11 GMT]]></title><description><![CDATA[<p>TyRoXx schrieb:</p>
<blockquote>
<p>Gibt es ein Argument gegen <code>struct</code> statt <code>namespace</code> ?</p>
</blockquote>
<p>Warum einen Typ nehmen, wenn man nur einen Namensraum braucht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963650</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 10 Oct 2010 22:27:11 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 22:33:50 GMT]]></title><description><![CDATA[<p><code>struct</code> ist auch ein Namensraum, kann aber im Gegensatz zu <code>namespace</code> nicht erweitert werden. Ein versehentliches Wiederverwenden des Namens führt mit <code>struct</code> zu einem Compiler-Fehler. Außerdem ist dem Leser sofort klar, dass der Namensraum nur dem <code>enum</code> dient.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963653</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Sun, 10 Oct 2010 22:33:50 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 22:41:07 GMT]]></title><description><![CDATA[<p>Dafür kann man <code>struct</code> versehentlich instanziieren oder an Orten einsetzen, wo ein Typ benötigt wird. Es besteht auch die Gefahr, dass der Benutzer <code>MyEnum enumVar;</code> statt <code>MyEnum::Id enumVar;</code> schreibt und der Code trotzdem kompiliert.</p>
<p>Semantisch gesehen will man nur einen Namensraum zur Gliederung, daher scheint mir <code>namespace</code> am naheliegendsten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963655</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 10 Oct 2010 22:41:07 GMT</pubDate></item><item><title><![CDATA[Reply to enums enum::type oder type on Sun, 10 Oct 2010 22:47:49 GMT]]></title><description><![CDATA[<p>Diese &quot;Lösung&quot; kommt wohl eher nicht in Frage:</p>
<pre><code class="language-cpp">struct Number
{
	enum Enum
	{
	};
private:
	Number();
	Number(const Number &amp;);
};
</code></pre>
<p>Aber vielleicht das hier für mehr Komfort:</p>
<pre><code class="language-cpp">typedef Number::Enum NumberId;
</code></pre>
<p>Außerdem kann man den zusätzlichen <code>struct</code> -Typ nicht sinnvoll verwenden, ohne Fehler zu erzeugen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1963656</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1963656</guid><dc:creator><![CDATA[TyRoXx]]></dc:creator><pubDate>Sun, 10 Oct 2010 22:47:49 GMT</pubDate></item></channel></rss>