<?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[C++ Vererbung]]></title><description><![CDATA[<p>Hallo ich habe ein Problem mit Vererbung in C++.<br />
Ich arbeite mit Visual Basic 201=:</p>
<p>Ich habe eine Klasse die von einer anderen erbt:</p>
<pre><code>//Basic 2D Object (Header-File)

class Object
{
	private:
		float x;										//position on x-axis
		float y;										//position on y-axis
		bool draw;										//should &quot;Object&quot; rendered

	public:
		//Konstruktor
		Object(float x, float y);

		//Destruktor
		~Object();

		//Methoden
		float getX();
		float getY();
		bool isDrawing();

		void setX(float newX);
		void setY(float newY);
		void setDrawing(bool newDraw);
};
</code></pre>
<pre><code>//Basic movable 2D Object (Header-File)

#include &quot;Object.h&quot;

class MovableObject : public Object
{
	private:
		float xSpeed;									//speed in horizontal-direction
		float ySpeed;									//speed in vertical-direction

	public:
		//Konstruktor
		MovableObject(float x, float y);

		//Methoden
		float getXSpeed();
		float getYSpeed();

		void setXSpeed(float xSpeed);
		void setYSpeed(float ySpeed);
};
</code></pre>
<p>Und erhalte folgende Fehlermeldung:</p>
<p>1&gt;------ Erstellen gestartet: Projekt: game_lib, Konfiguration: Debug Win32 ------<br />
1&gt; main.cpp<br />
1&gt;c:\programming\c\game_lib\game_lib\object.h(4): error C2011: 'Object': 'class' Typneudefinition<br />
1&gt; c:\programming\c\game_lib\game_lib\object.h(4): Siehe Deklaration von 'Object'<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.h(6): error C2504: 'Object': Basisklasse undefiniert<br />
1&gt; MovableObject.cpp<br />
1&gt;c:\programming\c\game_lib\game_lib\object.h(4): error C2011: 'Object': 'class' Typneudefinition<br />
1&gt; c:\programming\c\game_lib\game_lib\object.h(4): Siehe Deklaration von 'Object'<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.h(6): error C2504: 'Object': Basisklasse undefiniert<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.cpp(8): error C2614: 'MovableObject': Unzulässige Elementinitialisierung: 'Object' ist weder Basis noch Element<br />
1&gt; Code wird generiert...<br />
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/318712/c-vererbung</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Jul 2026 17:25:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/318712.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Jul 2013 17:08:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C++ Vererbung on Tue, 23 Jul 2013 17:08:57 GMT]]></title><description><![CDATA[<p>Hallo ich habe ein Problem mit Vererbung in C++.<br />
Ich arbeite mit Visual Basic 201=:</p>
<p>Ich habe eine Klasse die von einer anderen erbt:</p>
<pre><code>//Basic 2D Object (Header-File)

class Object
{
	private:
		float x;										//position on x-axis
		float y;										//position on y-axis
		bool draw;										//should &quot;Object&quot; rendered

	public:
		//Konstruktor
		Object(float x, float y);

		//Destruktor
		~Object();

		//Methoden
		float getX();
		float getY();
		bool isDrawing();

		void setX(float newX);
		void setY(float newY);
		void setDrawing(bool newDraw);
};
</code></pre>
<pre><code>//Basic movable 2D Object (Header-File)

#include &quot;Object.h&quot;

class MovableObject : public Object
{
	private:
		float xSpeed;									//speed in horizontal-direction
		float ySpeed;									//speed in vertical-direction

	public:
		//Konstruktor
		MovableObject(float x, float y);

		//Methoden
		float getXSpeed();
		float getYSpeed();

		void setXSpeed(float xSpeed);
		void setYSpeed(float ySpeed);
};
</code></pre>
<p>Und erhalte folgende Fehlermeldung:</p>
<p>1&gt;------ Erstellen gestartet: Projekt: game_lib, Konfiguration: Debug Win32 ------<br />
1&gt; main.cpp<br />
1&gt;c:\programming\c\game_lib\game_lib\object.h(4): error C2011: 'Object': 'class' Typneudefinition<br />
1&gt; c:\programming\c\game_lib\game_lib\object.h(4): Siehe Deklaration von 'Object'<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.h(6): error C2504: 'Object': Basisklasse undefiniert<br />
1&gt; MovableObject.cpp<br />
1&gt;c:\programming\c\game_lib\game_lib\object.h(4): error C2011: 'Object': 'class' Typneudefinition<br />
1&gt; c:\programming\c\game_lib\game_lib\object.h(4): Siehe Deklaration von 'Object'<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.h(6): error C2504: 'Object': Basisklasse undefiniert<br />
1&gt;c:\programming\c\game_lib\game_lib\movableobject.cpp(8): error C2614: 'MovableObject': Unzulässige Elementinitialisierung: 'Object' ist weder Basis noch Element<br />
1&gt; Code wird generiert...<br />
========== Erstellen: 0 erfolgreich, Fehler bei 1, 0 aktuell, 0 übersprungen ==========</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2340687</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2340687</guid><dc:creator><![CDATA[Gremilo]]></dc:creator><pubDate>Tue, 23 Jul 2013 17:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Vererbung on Tue, 23 Jul 2013 17:35:14 GMT]]></title><description><![CDATA[<p>Vermutlich <em>Include Guards</em> vergessen. Falls dies das Problem nicht lösen sollte, dann konstruiere bitte ein Minimalbeispiel, das sich (bis auf den Fehler) compilieren lässt. Siehe dritter Link in meiner Signatur.</p>
<p>Außerdem hast du entweder die <em>Regel der großen Drei</em> verletzt oder, wahrscheinlicher, einen völlig sinnlosen Destruktor geschrieben. Siehe<br />
<a href="http://en.wikipedia.org/wiki/Special_member_functions" rel="nofollow">http://en.wikipedia.org/wiki/Special_member_functions</a></p>
<p><em>Const correctness</em> ist ein weiteres Stichowrt, mit dem du dich mal beschäftigen solltest</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2340695</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2340695</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 23 Jul 2013 17:35:14 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Vererbung on Tue, 23 Jul 2013 18:16:53 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Gremilo schrieb:</p>
<blockquote>
<p>Hallo ich habe ein Problem mit Vererbung in C++.<br />
Ich arbeite mit Visual Basic 201=:</p>
</blockquote>
<p>du meinst wohl Visual <strong>Studio</strong> 2010. Bei Basic hätte ich auch Probleme mit der Vererbung von C++ <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/2340705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2340705</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Tue, 23 Jul 2013 18:16:53 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Vererbung on Wed, 24 Jul 2013 18:36:04 GMT]]></title><description><![CDATA[<p>Habs gelöst bekommen. Es lag am Konstruktor.</p>
<p>Haha ja Visual Basic wäre ein bisschen schlecht gewesen <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/2340975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2340975</guid><dc:creator><![CDATA[Gremilo]]></dc:creator><pubDate>Wed, 24 Jul 2013 18:36:04 GMT</pubDate></item><item><title><![CDATA[Reply to C++ Vererbung on Thu, 25 Jul 2013 10:47:44 GMT]]></title><description><![CDATA[<p>Mit C/C++ Kompilierer geht man viel besser zu kompilieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /> (ich habe es versucht)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2341103</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2341103</guid><dc:creator><![CDATA[Fredy Kruger]]></dc:creator><pubDate>Thu, 25 Jul 2013 10:47:44 GMT</pubDate></item></channel></rss>