<?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[Übergameparameter will nicht]]></title><description><![CDATA[<p>Obwohl ich meine Klasse inkludiere, heißt es:</p>
<p>d:\c++\test2\items.h(14) : error C2061: Syntaxfehler : Bezeichner 'PLAYER'<br />
d:\c++\test2\items.h(22) : error C2061: Syntaxfehler : Bezeichner 'PLAYER'</p>
<p>Der Code:</p>
<p>player.h</p>
<pre><code class="language-cpp">#ifndef _PLAYER_H_
#define _PLAYER_H_

//***INCLUDES***//
#include &quot;items.h&quot;

//***CLASS PLAYER***//
class PLAYER
{
public:
	signed health;
};

#endif
</code></pre>
<p>items.h</p>
<pre><code class="language-cpp">#ifndef _ITEMS_H_
#define _ITEMS_H_

//***INCLUDES***//
#include &quot;player.h&quot;

//***CLASS ITEM***//
class Item 
{ 
public:
	virtual void use(PLAYER &amp;player) = 0; 
}; 

//***ITEM CLASSES***//
class Healthpotion : public Item 
{ 
public: 
    virtual void use(PLAYER &amp;player) 
    {
		player.health += 100;
    } 
}; 

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/131653/übergameparameter-will-nicht</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 05:52:18 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/131653.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 04 Jan 2006 22:18:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Übergameparameter will nicht on Wed, 04 Jan 2006 22:18:28 GMT]]></title><description><![CDATA[<p>Obwohl ich meine Klasse inkludiere, heißt es:</p>
<p>d:\c++\test2\items.h(14) : error C2061: Syntaxfehler : Bezeichner 'PLAYER'<br />
d:\c++\test2\items.h(22) : error C2061: Syntaxfehler : Bezeichner 'PLAYER'</p>
<p>Der Code:</p>
<p>player.h</p>
<pre><code class="language-cpp">#ifndef _PLAYER_H_
#define _PLAYER_H_

//***INCLUDES***//
#include &quot;items.h&quot;

//***CLASS PLAYER***//
class PLAYER
{
public:
	signed health;
};

#endif
</code></pre>
<p>items.h</p>
<pre><code class="language-cpp">#ifndef _ITEMS_H_
#define _ITEMS_H_

//***INCLUDES***//
#include &quot;player.h&quot;

//***CLASS ITEM***//
class Item 
{ 
public:
	virtual void use(PLAYER &amp;player) = 0; 
}; 

//***ITEM CLASSES***//
class Healthpotion : public Item 
{ 
public: 
    virtual void use(PLAYER &amp;player) 
    {
		player.health += 100;
    } 
}; 

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/957247</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957247</guid><dc:creator><![CDATA[Aedyn-notloggedin]]></dc:creator><pubDate>Wed, 04 Jan 2006 22:18:28 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Wed, 04 Jan 2006 22:22:21 GMT]]></title><description><![CDATA[<p>Du bindest die beiden Header-Dateien gegenseitig ein. Das hat zur Folge, dass in der player.h die items.h geöffnet wird und im Code die Klasse PLAYER (ich hoffe die Großschreibung ist nur zur Hervorhebung gedacht) noch nicht bekannt ist.</p>
<p>Du kannst das mittels einer Forward-Deklaration lösen:</p>
<pre><code class="language-cpp">// in items.h
#include &quot;player.h&quot;

class PLAYER;

class Item
{
...
</code></pre>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957252</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957252</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Wed, 04 Jan 2006 22:22:21 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Wed, 04 Jan 2006 23:26:48 GMT]]></title><description><![CDATA[<p>Funktioniert nicht:</p>
<p>d:\c++\test2\items.h(24) : error C2027: Verwendung des undefinierten Typs &quot;PLAYER&quot;<br />
d:\c++\test2\items.h(7) : Siehe Deklaration von 'PLAYER'<br />
d:\c++\test2\items.h(24) : error C2228: Der linke Teil von '.health' muss eine Klasse/Struktur/Union sein</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957292</guid><dc:creator><![CDATA[Aedyn-notloggedin]]></dc:creator><pubDate>Wed, 04 Jan 2006 23:26:48 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Wed, 04 Jan 2006 23:47:16 GMT]]></title><description><![CDATA[<p>du kannst use() nicht inline declarieren.<br />
implementiere use(...) in einer separaten .cc Datei<br />
Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957300</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Wed, 04 Jan 2006 23:47:16 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Thu, 05 Jan 2006 03:56:58 GMT]]></title><description><![CDATA[<p>Kannst du mir vielleicht einen Beispielcode schreiben?<br />
Bei mir funktioniert das immer noch nicht ..</p>
<p>D:\C++\Test2\items.cpp(5) : error C2511: 'use' : Überladene Member-Funktion 'void (class PLAYER &amp;)' nicht in 'Item' gefunden<br />
d:\c++\test2\items.h(13) : Siehe Deklaration von 'Item'<br />
Fehler beim Ausführen von cl.exe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957381</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957381</guid><dc:creator><![CDATA[Aedyn-notloggedin]]></dc:creator><pubDate>Thu, 05 Jan 2006 03:56:58 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Thu, 05 Jan 2006 09:59:24 GMT]]></title><description><![CDATA[<p>Im player.h brauchst Du item.h nicht. Laß es einfach weg, dann funktioniert das.</p>
<p>Tommi</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957511</guid><dc:creator><![CDATA[tntnet]]></dc:creator><pubDate>Thu, 05 Jan 2006 09:59:24 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Thu, 05 Jan 2006 11:32:31 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//player.h

#ifndef _PLAYER_H_
#define _PLAYER_H_

//***INCLUDES***//

#include &quot;items.h&quot;

//***CLASS PLAYER***//
class PLAYER {
public:
    signed health;
};

#endif
</code></pre>
<pre><code class="language-cpp">//items.h

#ifndef _ITEMS_H_
#define _ITEMS_H_

//***INCLUDES***//
#include &quot;player.h&quot;

class PLAYER;  // wirkt zwar irgendwie pervers
               // da player.h schon #included
               // aber PLAYER ist hier noch nicht definiert 
               // da player.h sofort wieder dieses file #includiert

//***CLASS ITEM***//
class Item {
   public:
    virtual void use(PLAYER &amp;player) = 0;
};

//***ITEM CLASSES***//
class Healthpotion : public Item {
   public:
    virtual void use(PLAYER &amp;player);  // hier nur declaration
};

#endif
</code></pre>
<pre><code class="language-cpp">// items.cc
void Healthpotion::use(PLAYER &amp;player) { 
        player.health += 100;
}
</code></pre>
<p>Wie tntnet schon gesagt hat brauchst in diesem Fall das #include &quot;items.h&quot; in player.h gar nicht ( kann aber noch kommen ).<br />
Ich würde in so einem Fall wenn 2 Klassen voneinander abhängig sind die gegenseitigen #include's überhaupt weglassen und nur mit forward declarations arbeiten. Der Nachteil ist dann aber natürlich dass du memberfunktionen die die andere Klasse verwenden nicht mehr inline declarieren kannst.</p>
<p>Kurt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/957609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/957609</guid><dc:creator><![CDATA[ZuK]]></dc:creator><pubDate>Thu, 05 Jan 2006 11:32:31 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Thu, 05 Jan 2006 22:13:17 GMT]]></title><description><![CDATA[<p>Bei deinem Code:</p>
<p>D:\C++\Test2\items.cpp(2) : error C2653: 'Healthpotion' : Keine Klasse oder Namespace<br />
D:\C++\Test2\items.cpp(2) : error C2065: 'PLAYER' : nichtdeklarierter Bezeichner<br />
D:\C++\Test2\items.cpp(2) : error C2065: 'player' : nichtdeklarierter Bezeichner<br />
D:\C++\Test2\items.cpp(2) : error C2448: '&lt;unbekannt&gt;' : Funktionsstil-Initialisierung scheint eine Funktionsdefinition zu sein<br />
main.cpp<br />
Fehler beim Ausführen von cl.exe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/958300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/958300</guid><dc:creator><![CDATA[Aedyn-notloggedin]]></dc:creator><pubDate>Thu, 05 Jan 2006 22:13:17 GMT</pubDate></item><item><title><![CDATA[Reply to Übergameparameter will nicht on Thu, 05 Jan 2006 22:14:29 GMT]]></title><description><![CDATA[<p>hast nen header vergessen sorry</p>
]]></description><link>https://www.c-plusplus.net/forum/post/958301</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/958301</guid><dc:creator><![CDATA[Aedyn-notloggedin]]></dc:creator><pubDate>Thu, 05 Jan 2006 22:14:29 GMT</pubDate></item></channel></rss>