<?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[enum als Datentyp?]]></title><description><![CDATA[<p>Hallo.<br />
Habe folgende Frage:<br />
Habe nen enum</p>
<pre><code class="language-cpp">enum Inputdata {MOVE_UP, MOVE_DOWN, MOVE_RIGHT, MOVE_LEFT, FIRE};
</code></pre>
<p>Nun kann ich ja eine Variable erstellen wie</p>
<pre><code class="language-cpp">Inputdata Data = FIRE;
</code></pre>
<p>Aber wie kann ich mein enum auch für Funktionen als Rückgabetyp nutzen?</p>
<pre><code class="language-cpp">Inputdata GetInput(void);
</code></pre>
<p>Da haut mit der Compiler immer Fehler raus: und sagt, er erkennt den Typ nicht:</p>
<blockquote>
<p>error C2143: Syntaxfehler: Es fehlt ';' vor 'Input::GetInput'<br />
error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.</p>
</blockquote>
<p>Wie kann ich nun angeben, dass das mein Typ ist?<br />
typename ist so weit ich weiß ja nur für templates...</p>
<p>Stehe gerade etwas auf dem Schlauch...</p>
<p>MfG<br />
Hundefutter</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/236394/enum-als-datentyp</link><generator>RSS for Node</generator><lastBuildDate>Thu, 24 Sep 2026 00:30:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/236394.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 14 Mar 2009 14:43:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 14:43:53 GMT]]></title><description><![CDATA[<p>Hallo.<br />
Habe folgende Frage:<br />
Habe nen enum</p>
<pre><code class="language-cpp">enum Inputdata {MOVE_UP, MOVE_DOWN, MOVE_RIGHT, MOVE_LEFT, FIRE};
</code></pre>
<p>Nun kann ich ja eine Variable erstellen wie</p>
<pre><code class="language-cpp">Inputdata Data = FIRE;
</code></pre>
<p>Aber wie kann ich mein enum auch für Funktionen als Rückgabetyp nutzen?</p>
<pre><code class="language-cpp">Inputdata GetInput(void);
</code></pre>
<p>Da haut mit der Compiler immer Fehler raus: und sagt, er erkennt den Typ nicht:</p>
<blockquote>
<p>error C2143: Syntaxfehler: Es fehlt ';' vor 'Input::GetInput'<br />
error C4430: Fehlender Typspezifizierer - int wird angenommen. Hinweis: &quot;default-int&quot; wird von C++ nicht unterstützt.</p>
</blockquote>
<p>Wie kann ich nun angeben, dass das mein Typ ist?<br />
typename ist so weit ich weiß ja nur für templates...</p>
<p>Stehe gerade etwas auf dem Schlauch...</p>
<p>MfG<br />
Hundefutter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679888</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679888</guid><dc:creator><![CDATA[Hundefutter]]></dc:creator><pubDate>Sat, 14 Mar 2009 14:43:53 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 14:51:13 GMT]]></title><description><![CDATA[<p>Das geht schon. Zeig mal den umliegenden Code. Da stimmt was nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679893</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 14 Mar 2009 14:51:13 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 15:15:45 GMT]]></title><description><![CDATA[<p>Hast du das <code>enum</code> <strong>vor</strong> der Funktion deklariert? Der Typ muss zu dem Zeitpunkt natürlich bekannt sein...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679904</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679904</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 14 Mar 2009 15:15:45 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 15:17:51 GMT]]></title><description><![CDATA[<p>Header:</p>
<pre><code class="language-cpp">#ifndef INPUT_H_
#define INPUT_H_

#include &lt;dinput.h&gt;

class Input
{
	public:

		enum InputDevice {KEYBOARD, MOUSE};
		enum Inputdata {MOVE_UP, MOVE_DOWN, MOVE_RIGHT, MOVE_LEFT, FIRE};

		Input(HWND hWnd, HINSTANCE hInst, InputDevice Device);
		~Input();
		Inputdata GetInput(void);

	protected:

		void initKeyboard(HWND hWnd);
		void initMouse(HWND hWnd);

		Inputdata GetKeyboardInput(void);
		Inputdata GetMouseInput(void);	

		LPDIRECTINPUT8 m_DI;
		LPDIRECTINPUTDEVICE8 m_DIDevice;

		InputDevice m_CurrentDevice;
};

#endif /*INPUT_H_*/
</code></pre>
<p>cpp-Datei:</p>
<pre><code class="language-cpp">#include &quot;Input.h&quot;

Input::Input(HWND hWnd, HINSTANCE hInst, InputDevice Device)
{
	m_DI = NULL;
	m_DIDevice = NULL;

	// create DirectInput8-Object
    if(FAILED(DirectInput8Create(hInst, DIRECTINPUT_VERSION, 
                                 IID_IDirectInput8,(void**)&amp;m_DI,NULL)))
    { 
        // throw exception
    } 

	// set device
	m_CurrentDevice = Device;

    // init chosen device
    switch(m_CurrentDevice)
    {
        case KEYBOARD:
                initKeyboard(hWnd);
            break;
        case MOUSE:
                initMouse(hWnd);
            break;            
        default:
                m_CurrentDevice = KEYBOARD;
                initKeyboard(hWnd);
    }
}

Input::~Input()
{

}

Inputdata Input::GetInput()
{

}

void Input::initKeyboard(HWND hWnd)
{

}

void Input::initMouse(HWND hWnd)
{

}
</code></pre>
<p>Die Fehler gibt er mir in der cpp-Datei bei der entsprechenden Funktion an.</p>
<p>MfG<br />
Hundefutter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679906</guid><dc:creator><![CDATA[Hundefutter]]></dc:creator><pubDate>Sat, 14 Mar 2009 15:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 15:20:54 GMT]]></title><description><![CDATA[<p>Du hättest sagen können, dass sich das <code>enum</code> in einer Klasse befindet...</p>
<p>Natürlich musst du in diesem Fall die Klasse mittels Scope-Operator <code>::</code> angeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679909</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679909</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sat, 14 Mar 2009 15:20:54 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 15:24:05 GMT]]></title><description><![CDATA[<p>Alles klar, danke.<br />
Hatte mich auch schon stark gewundert, warum das nicht funktioniert hat.<br />
Aber klar, das hatte ich vergessen.</p>
<p>Vielen Dank!</p>
<p>MfG<br />
Hundefutter</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1679910</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1679910</guid><dc:creator><![CDATA[Hundefutter]]></dc:creator><pubDate>Sat, 14 Mar 2009 15:24:05 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 22:57:16 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>...</p>
</blockquote>
<p>Mich intressiert wie es geht und habe nicht ganz genau verstanden wie du das mit dem :: Operator meinst. Kannst du vielleicht bitte ein Beispiel dazu machen wie das aus zu sehen hat? Wäre nett.</p>
<p>fy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1680158</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1680158</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Sat, 14 Mar 2009 22:57:16 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 23:16:30 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">Input::Inputdata Input::GetInput() { ... }
</code></pre>
<p>Nötig ist das, weil der Compiler, genauso wie wir Menschen, von links nach rechts und von oben nach unten arbeitet. Dadurch sieht er zuerst den Rückgabewert und <em>dann</em> erst, dass wir eine Methode der Klasse Input deklarieren. Wenn in einer Methode ein Parameter vom Typ Inputdata ist, braucht's das <code>Input::</code> nicht:</p>
<pre><code class="language-cpp">void Input::SetInput( Inputdata id ) { ... }
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1680159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1680159</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 14 Mar 2009 23:16:30 GMT</pubDate></item><item><title><![CDATA[Reply to enum als Datentyp? on Sat, 14 Mar 2009 23:23:30 GMT]]></title><description><![CDATA[<p>Alles klar, verstanden, danke !</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1680163</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1680163</guid><dc:creator><![CDATA[freaky]]></dc:creator><pubDate>Sat, 14 Mar 2009 23:23:30 GMT</pubDate></item></channel></rss>