<?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[Methodenzugriff auf Vaterklasse]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe 2 Klassen (Fortbewegungsmittel und Flugzeug)</p>
<p>Dabei erbt Flugzeug von Fortbewegungsmittel.</p>
<p>In beiden Klassen habe ich eine Methode &quot;string sag_was()&quot; implementiert.</p>
<p>Fortbewegungsmittel</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class Fortbewegungsmittel
{
protected:
	float x,y;
public:

	Fortbewegungsmittel(float x_,float y_):x(x_),y(y_){}

	string sag_was() 
	{
		ostringstream s1;
		s1&lt;&lt;&quot;Ich befinde mich bei&quot; &lt;&lt; &quot;x:&quot; &lt;&lt; x &lt;&lt; &quot; y: &quot; &lt;&lt;y;

		string s;
		s+=s1.str();
		return s;

	}

	void set_all(float x_, float y_) 
	{
		x=x_;
		y=y_;
	}

	void set_x(float x_) 
	{
		x=x_;
	}

	void set_y(float y_)
	{
		y=y_;
	}

	float get_x() 
	{
		return x;
	}

	float get_y() 
	{
		return y;
	}
};
</code></pre>
<p>Flugzeug</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;string&gt;
#include &quot;Fortbewegungsmittel.h&quot;

class Flugzeug:public Fortbewegungsmittel
{
	float hoehe;
public:
	Flugzeug(float x_, float y_,float hoehe_):Fortbewegungsmittel(x_,y_),hoehe(hoehe_) 
	{

	}

	string sag_was() 
	{
		ostringstream s1;
		//s1 &lt;&lt;   sag_was() Methode der Klasse Fortbewegungsmittel
		s1 &lt;&lt; &quot;hoehe: &quot; &lt;&lt; hoehe;

		string s;
		s+=s1.str();
		return s;
	}

	void set_hoehe(float hoehe_) 
	{
		hoehe=hoehe_;
	}

	float get_hoehe()
	{
		return hoehe;
	}

};
</code></pre>
<p>Wie kann ich nun in der Methode &quot;string sag_was()&quot; in Flugzeug die Methode &quot;string sag_was()&quot; der Klasse Fortbewegungsmittel aufrufen?<br />
(In Java geht das mit super. aber irgendwie kennt c++ super. nicht)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/192457/methodenzugriff-auf-vaterklasse</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 13:09:54 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/192457.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 14 Sep 2007 16:48:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Methodenzugriff auf Vaterklasse on Fri, 14 Sep 2007 16:48:08 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe 2 Klassen (Fortbewegungsmittel und Flugzeug)</p>
<p>Dabei erbt Flugzeug von Fortbewegungsmittel.</p>
<p>In beiden Klassen habe ich eine Methode &quot;string sag_was()&quot; implementiert.</p>
<p>Fortbewegungsmittel</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

class Fortbewegungsmittel
{
protected:
	float x,y;
public:

	Fortbewegungsmittel(float x_,float y_):x(x_),y(y_){}

	string sag_was() 
	{
		ostringstream s1;
		s1&lt;&lt;&quot;Ich befinde mich bei&quot; &lt;&lt; &quot;x:&quot; &lt;&lt; x &lt;&lt; &quot; y: &quot; &lt;&lt;y;

		string s;
		s+=s1.str();
		return s;

	}

	void set_all(float x_, float y_) 
	{
		x=x_;
		y=y_;
	}

	void set_x(float x_) 
	{
		x=x_;
	}

	void set_y(float y_)
	{
		y=y_;
	}

	float get_x() 
	{
		return x;
	}

	float get_y() 
	{
		return y;
	}
};
</code></pre>
<p>Flugzeug</p>
<pre><code class="language-cpp">#include &lt;sstream&gt;
#include &lt;string&gt;
#include &quot;Fortbewegungsmittel.h&quot;

class Flugzeug:public Fortbewegungsmittel
{
	float hoehe;
public:
	Flugzeug(float x_, float y_,float hoehe_):Fortbewegungsmittel(x_,y_),hoehe(hoehe_) 
	{

	}

	string sag_was() 
	{
		ostringstream s1;
		//s1 &lt;&lt;   sag_was() Methode der Klasse Fortbewegungsmittel
		s1 &lt;&lt; &quot;hoehe: &quot; &lt;&lt; hoehe;

		string s;
		s+=s1.str();
		return s;
	}

	void set_hoehe(float hoehe_) 
	{
		hoehe=hoehe_;
	}

	float get_hoehe()
	{
		return hoehe;
	}

};
</code></pre>
<p>Wie kann ich nun in der Methode &quot;string sag_was()&quot; in Flugzeug die Methode &quot;string sag_was()&quot; der Klasse Fortbewegungsmittel aufrufen?<br />
(In Java geht das mit super. aber irgendwie kennt c++ super. nicht)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1365405</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1365405</guid><dc:creator><![CDATA[MisterX]]></dc:creator><pubDate>Fri, 14 Sep 2007 16:48:08 GMT</pubDate></item><item><title><![CDATA[Reply to Methodenzugriff auf Vaterklasse on Fri, 14 Sep 2007 16:51:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">Fortbewegungsmittel::sag_was()
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1365413</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1365413</guid><dc:creator><![CDATA[The-Kenny]]></dc:creator><pubDate>Fri, 14 Sep 2007 16:51:55 GMT</pubDate></item></channel></rss>