<?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[Problem mit der Abletung einer Klasse]]></title><description><![CDATA[<p>Hallo ich stehe irgendwie auf dem Schlauch .<br />
Ich habe eine Basisklasse vbPerson, und möchte nun die Klasse vbPlayer davon ableiten. Ich kann das auch ohne Fehler komilieren allerdings kommt bei der ausführung nicht das gewünschte resultat heraus. ich habe zu debug zwecke mal einige ausgaben gemacht hier der code. ich hoffe es kann mir jemand den richtigen tipp geben dankeschön.</p>
<p>Auszug aus vbPerson.cpp</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPerson.cpp

#include &quot;vbPerson.h&quot;

// **********************************************
// Standart - Konstruktor
vbPerson::vbPerson()
{
	vbPerson(&quot;&quot;,&quot;&quot;,g_iAgeMin);
}

// **********************************************
// Konstruktor mit Parameter
vbPerson::vbPerson(string firstname, string familyname, int age)
{
	vbPerson(firstname,familyname,age);	
}

vbPerson::vbPerson(string firstname, string familyname, int age, float min, float max)
{
	sFirstName = firstname;
	sFamilyName = familyname;
	iAge = age;

	SetTechnicToDefault(min, max);

	cout &lt;&lt; &quot;Person\n&quot;;
}

// **********************************************
// Destruktor
vbPerson::~vbPerson()
{
}

// *****************
</code></pre>
<p>VbPlayer.cpp</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPlayer.cpp

#include &quot;vbPlayer.h&quot;

// **********************************************

vbPlayer::vbPlayer()
{

	cout &lt;&lt; &quot;Player \n&quot;;
}
</code></pre>
<p>und die header dateien</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPerson.h

#ifndef PERSON_H
#define PERSON_H

#include &quot;general.h&quot;

class vbPerson
{
public:
	// **********************************************
	// Funktionen - Public
	vbPerson();
	vbPerson(string firstname, string familyname, int age);
	vbPerson(string firstname, string familyname, int age, float min, float max);
	~vbPerson();

	const string GetFirstName() { return sFirstName; }
	const string GetFamilyName() { return sFamilyName; }
	const int GetAge() { return iAge; }

	vbResult IncreaseAge();

private:
	// **********************************************
	// Funktionen - Private
	vbResult SetTechnicToDefault(float min, float max);

private:
	// **********************************************
	// Vairablen - Private
	string sFirstName, sFamilyName;
	int iAge;
	Technic sTechnic;

};

#endif
</code></pre>
<pre><code class="language-cpp">// **********************************************
// File : vbPlayer.h

#ifndef PLAYER_H
#define PLAYER_H

#include &quot;vbPerson.h&quot;
#include &quot;general.h&quot;

class vbPlayer : public vbPerson 
{
public:
	// **********************************************
	// Funktionen - Public
	vbPlayer();

private:
	// **********************************************
	// Funktionen - Private

private:
	// **********************************************
	// Vairablen - Private

};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/259121/problem-mit-der-abletung-einer-klasse</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 01:22:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/259121.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Jan 2010 12:09:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit der Abletung einer Klasse on Tue, 19 Jan 2010 12:09:09 GMT]]></title><description><![CDATA[<p>Hallo ich stehe irgendwie auf dem Schlauch .<br />
Ich habe eine Basisklasse vbPerson, und möchte nun die Klasse vbPlayer davon ableiten. Ich kann das auch ohne Fehler komilieren allerdings kommt bei der ausführung nicht das gewünschte resultat heraus. ich habe zu debug zwecke mal einige ausgaben gemacht hier der code. ich hoffe es kann mir jemand den richtigen tipp geben dankeschön.</p>
<p>Auszug aus vbPerson.cpp</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPerson.cpp

#include &quot;vbPerson.h&quot;

// **********************************************
// Standart - Konstruktor
vbPerson::vbPerson()
{
	vbPerson(&quot;&quot;,&quot;&quot;,g_iAgeMin);
}

// **********************************************
// Konstruktor mit Parameter
vbPerson::vbPerson(string firstname, string familyname, int age)
{
	vbPerson(firstname,familyname,age);	
}

vbPerson::vbPerson(string firstname, string familyname, int age, float min, float max)
{
	sFirstName = firstname;
	sFamilyName = familyname;
	iAge = age;

	SetTechnicToDefault(min, max);

	cout &lt;&lt; &quot;Person\n&quot;;
}

// **********************************************
// Destruktor
vbPerson::~vbPerson()
{
}

// *****************
</code></pre>
<p>VbPlayer.cpp</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPlayer.cpp

#include &quot;vbPlayer.h&quot;

// **********************************************

vbPlayer::vbPlayer()
{

	cout &lt;&lt; &quot;Player \n&quot;;
}
</code></pre>
<p>und die header dateien</p>
<pre><code class="language-cpp">// **********************************************
// File : vbPerson.h

#ifndef PERSON_H
#define PERSON_H

#include &quot;general.h&quot;

class vbPerson
{
public:
	// **********************************************
	// Funktionen - Public
	vbPerson();
	vbPerson(string firstname, string familyname, int age);
	vbPerson(string firstname, string familyname, int age, float min, float max);
	~vbPerson();

	const string GetFirstName() { return sFirstName; }
	const string GetFamilyName() { return sFamilyName; }
	const int GetAge() { return iAge; }

	vbResult IncreaseAge();

private:
	// **********************************************
	// Funktionen - Private
	vbResult SetTechnicToDefault(float min, float max);

private:
	// **********************************************
	// Vairablen - Private
	string sFirstName, sFamilyName;
	int iAge;
	Technic sTechnic;

};

#endif
</code></pre>
<pre><code class="language-cpp">// **********************************************
// File : vbPlayer.h

#ifndef PLAYER_H
#define PLAYER_H

#include &quot;vbPerson.h&quot;
#include &quot;general.h&quot;

class vbPlayer : public vbPerson 
{
public:
	// **********************************************
	// Funktionen - Public
	vbPlayer();

private:
	// **********************************************
	// Funktionen - Private

private:
	// **********************************************
	// Vairablen - Private

};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1841329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1841329</guid><dc:creator><![CDATA[Fischkopf2009]]></dc:creator><pubDate>Tue, 19 Jan 2010 12:09:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit der Abletung einer Klasse on Tue, 19 Jan 2010 12:16:48 GMT]]></title><description><![CDATA[<p>Schau dir bitte nochmal genau in deinem Buch an, wie das mit den Konstruktoren funktioniert, was die genau machen und vor allem wie man sie verwenden kann.</p>
<pre><code class="language-cpp">vbPerson::vbPerson()
{
    vbPerson(&quot;&quot;,&quot;&quot;,g_iAgeMin); // was glaubst du versuchst du hier?
}
</code></pre>
<p>Sagt mir, dass du das noch nicht so verstanden hast.</p>
<p>TIP:<br />
Lagere die Initialisierung in eine Methode mit der Signatur des im Std-Konstruktor verwendeten Konstruktors aus, oder mach aus dem gleich einen Standard-Konstruktor, inem du ihm Default-Werte für die Parameter gibst:</p>
<pre><code class="language-cpp">class vbPerson
{
public:
    vbPerson( string firstname=string(), string secondname=string(), int age=g_iAgeMin );
};
</code></pre>
<p>Jetzt hast du automatisch einen Standard-Konstruktor!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1841335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1841335</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Tue, 19 Jan 2010 12:16:48 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit der Abletung einer Klasse on Tue, 19 Jan 2010 12:17:14 GMT]]></title><description><![CDATA[<p>Und was ist das Resultat und was sind deine Erwartungen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1841336</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1841336</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 19 Jan 2010 12:17:14 GMT</pubDate></item></channel></rss>