<?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[vererbung[gelöst]]]></title><description><![CDATA[<p>Hey, mach gerade alte Aufgaben zur vererbung und komme da nicht weiter.</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
using namespace std;

class ICEAH_Artikel{
public:
	static int count;
	string name;
	string beschreibung;
	virtual string LangeBeschreibung();
	ICEAH_Artikel(){
		count++;
	}
};
class ICEAH_Moebel : public ICEAH_Artikel{
public:
	string LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	ICEAH_Moebel IM;
	return 0;
}
</code></pre>
<p>wenn ich den Konstruktor aufrufe meckert er,</p>
<pre><code>ICEAH_Moebel IM;
</code></pre>
<p>sonst nicht. ka obs an der satischen variable liegt oder an falscher vererbung.<br />
find die compiler hinweise bei visual studio unter windows zimlich mau.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/270908/vererbung-gelöst</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 21:15:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/270908.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 20 Jul 2010 08:46:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 14:39:14 GMT]]></title><description><![CDATA[<p>Hey, mach gerade alte Aufgaben zur vererbung und komme da nicht weiter.</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
using namespace std;

class ICEAH_Artikel{
public:
	static int count;
	string name;
	string beschreibung;
	virtual string LangeBeschreibung();
	ICEAH_Artikel(){
		count++;
	}
};
class ICEAH_Moebel : public ICEAH_Artikel{
public:
	string LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	ICEAH_Moebel IM;
	return 0;
}
</code></pre>
<p>wenn ich den Konstruktor aufrufe meckert er,</p>
<pre><code>ICEAH_Moebel IM;
</code></pre>
<p>sonst nicht. ka obs an der satischen variable liegt oder an falscher vererbung.<br />
find die compiler hinweise bei visual studio unter windows zimlich mau.</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1928997</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1928997</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 14:39:14 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 08:51:37 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>Hey, mach gerade alte Aufgaben zur vererbung und komme da nicht weiter.</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
using namespace std;

class ICEAH_Artikel{
public:
	static int count;
	string name;
	string beschreibung;
	virtual string LangeBeschreibung();
	ICEAH_Artikel(){
		count++;
	}
};
class ICEAH_Moebel : public ICEAH_Artikel{
public:
	string LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
};

int _tmain(int argc, _TCHAR* argv[])
{
	ICEAH_Moebel IM;
	return 0;
}
</code></pre>
<p>wenn ich den Konstruktor aufrufe meckert er,</p>
<pre><code>ICEAH_Moebel IM;
</code></pre>
<p>sonst nicht. ka obs an der satischen variable liegt oder an falscher vererbung.<br />
find die compiler hinweise bei visual studio unter windows zimlich mau.</p>
<p>Gruß</p>
</blockquote>
<p>Leider ist meine Glaskugel defekt. Kannst Du mir die Fehlermeldung sagen?</p>
<p>Wenn das Dein kompletter Code ist, dann fehlt da noch die Definition von count.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1928999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1928999</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 08:51:37 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 08:54:56 GMT]]></title><description><![CDATA[<p>Fehler 1 error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: static int ICEAH_Artikel::count&quot; (?count@ICEAH_Artikel@@2HA)&quot;. Uebung 11.obj</p>
<p>Fehler 2 error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: virtual class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __thiscall ICEAH_Artikel::LangeBeschreibung(void)&quot; (?LangeBeschreibung@ICEAH_Artikel@@UAE?AV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_string@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@V?$allocator@D@2@@std@@XZ)&quot;. Uebung 11.obj</p>
<p>Fehler 3 fatal error LNK1120: 2 nicht aufgelöste externe Verweise. C:\Dokumente und Einstellungen\tim\Eigene Dateien\Visual Studio 2008\Projects\AufgabenUeberarbeitet\Debug\Uebung 11.exe 1</p>
<blockquote>
<p>Wenn das Dein kompletter Code ist, dann fehlt da noch die Definition von count.</p>
</blockquote>
<p>meinste das?</p>
<pre><code>static int count;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1929002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929002</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 08:54:56 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 09:04:40 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>meinste das?</p>
<pre><code>static int count;
</code></pre>
</blockquote>
<p>Ja. Du brauchst noch diese Zeile:</p>
<pre><code class="language-cpp">int ICEAH_Artikel::count = 0;
</code></pre>
<p>am besten nach der Klassendefinition.</p>
<p>Und diese Zeile:</p>
<pre><code class="language-cpp">virtual string LangeBeschreibung();
</code></pre>
<p>lässt Du entweder weg, oder Du schreibst auch noch ne definition oder Du definierst sie abstrakt.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929006</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 09:04:40 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 09:04:28 GMT]]></title><description><![CDATA[<p>ah nice, das hatte ich in er main, da hat es nicht funktioniert.</p>
<p>jetzt habe ich noch 2 fehler:</p>
<p>Fehler 1 error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: virtual class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __thiscall ICEAH_Artikel::LangeBeschreibung(void)&quot; (?LangeBeschreibung@ICEAH_Artikel@@UAE?AV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_string@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@V?$allocator@D@2@@std@@XZ)&quot;. Uebung 11.obj</p>
<p>Fehler 2 fatal error LNK1120: 1 nicht aufgelöste externe Verweise. C:\Dokumente und Einstellungen\tim\Eigene Dateien\Visual Studio 2008\Projects\AufgabenUeberarbeitet\Debug\Uebung 11.exe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929009</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 09:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 09:06:17 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>ah nice, das hatte ich in er main, da hat es nicht funktioniert.</p>
<p>jetzt habe ich noch 2 fehler:</p>
<p>Fehler 1 error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: virtual class std::basic_string&lt;char,struct std::char_traits&lt;char&gt;,class std::allocator&lt;char&gt; &gt; __thiscall ICEAH_Artikel::LangeBeschreibung(void)&quot; (?LangeBeschreibung@ICEAH_Artikel@@UAE?AV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_string@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">i</span><span class="mord mathit">n</span><span class="mord mathit" style="margin-right:0.03588em;">g</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@V?$allocator@D@2@@std@@XZ)&quot;. Uebung 11.obj</p>
<p>Fehler 2 fatal error LNK1120: 1 nicht aufgelöste externe Verweise. C:\Dokumente und Einstellungen\tim\Eigene Dateien\Visual Studio 2008\Projects\AufgabenUeberarbeitet\Debug\Uebung 11.exe</p>
</blockquote>
<p>Hab meinen Artikel noch ergänzt. Was diesen Fehler anbelangt. Sorry, hab's erst übersehen.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929011</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929011</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 09:06:17 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 09:29:16 GMT]]></title><description><![CDATA[<p>ich dachte das virtual bedeutet, dass sie abstrakt ist. also brauche ich es in der basisklasse ja auch nicht definieren, würde ja keinen sinn machen?</p>
<p>hab jetzt mal alles umstruktoriert:</p>
<p>uebung10.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
#include &quot;ICEAH_Moebel.h&quot;
using namespace std;
//int ICEAH_Artikel::count = 0; 
int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}
</code></pre>
<p>iceah artikel.h</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;
class ICEAH_Artikel{
public:
	static int count;
	string name;
	string beschreibung;
	virtual string LangeBeschreibung();
	ICEAH_Artikel();
};
</code></pre>
<p>iceah_moebel.h</p>
<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
using namespace std;

class ICEAH_Moebel {
public:
	string LangeBeschreibung();
	ICEAH_Moebel() ;
};
</code></pre>
<p>die jweiligen c++ dateien:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Moebel.h&quot;

	string ICEAH_Moebel::LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel::ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
</code></pre>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Artikel.h&quot;
ICEAH_Artikel::ICEAH_Artikel(){
		count++;
}
int ICEAH_Artikel::count = 0;
</code></pre>
<p>hab soweit es ging alles behoben, was ich gefunden hab. gibt immer noch 2 fehler:</p>
<p>Fehler 1 error C2011: 'ICEAH_Artikel': 'class' Typneudefinition c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_artikel.h 4</p>
<p>Fehler 2 error C2614: 'ICEAH_Moebel': Unzulässige Elementinitialisierung: 'ICEAH_Artikel' ist weder Basis noch Element c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_moebel.cpp 7</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929019</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929019</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 09:29:16 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 09:50:21 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>ich dachte das virtual bedeutet, dass sie abstrakt ist.<br />
also brauche ich es in der basisklasse ja auch nicht definieren, würde ja keinen sinn machen?</p>
</blockquote>
<p>Nein. Virtual ist eine Voraussetung, um eine Funktion abstrakt zu machen. Das heißt nicht: virtual == abstrakt:</p>
<pre><code class="language-cpp">class xyxx
{
  type normaleMemberFunk();
  virtual type virtuelleMemberFunk();
  virtual type abstrakteMemberFunk() = 0;
  type falscheMemberFunk() = 0;   // das geht nicht.
};
</code></pre>
<p>Rustyspoon schrieb:</p>
<blockquote>
<p>hab jetzt mal alles umstruktoriert:</p>
<p>uebung10.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
#include &quot;ICEAH_Moebel.h&quot;
using namespace std;
//int ICEAH_Artikel::count = 0; 
int _tmain(int argc, _TCHAR* argv[])
{
	return 0;
}
</code></pre>
<p>iceah artikel.h</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;
using namespace std;
class ICEAH_Artikel{
public:
	static int count;
	string name;
	string beschreibung;
	virtual string LangeBeschreibung();
	ICEAH_Artikel();
};
</code></pre>
<p>iceah_moebel.h</p>
<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
using namespace std;

class ICEAH_Moebel {
public:
	string LangeBeschreibung();
	ICEAH_Moebel() ;
};
</code></pre>
<p>die jweiligen c++ dateien:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Moebel.h&quot;

	string ICEAH_Moebel::LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel::ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
</code></pre>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Artikel.h&quot;
ICEAH_Artikel::ICEAH_Artikel(){
		count++;
}
int ICEAH_Artikel::count = 0;
</code></pre>
<p>hab soweit es ging alles behoben, was ich gefunden hab. gibt immer noch 2 fehler:</p>
<p>Fehler 1 error C2011: 'ICEAH_Artikel': 'class' Typneudefinition c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_artikel.h 4</p>
</blockquote>
<p>Das passiert gerne, wenn Header andere HEader includieren. Abhilfe:</p>
<pre><code class="language-cpp">#ifndef HEADER_NAME_H
#define HEADER_NAME_H

...

#endif
</code></pre>
<p>Wenn Du Dir sowas um deine eigentliche Header angewöhnst, kannst Du effektiv verhindern, daß der Präprozessor eine HEaderdatei zweimal einfügt und Du Dir um die Reihenfolge der includes keine Gedanken machen mußt.</p>
<p>Rustyspoon schrieb:</p>
<blockquote>
<p>Fehler 2 error C2614: 'ICEAH_Moebel': Unzulässige Elementinitialisierung: 'ICEAH_Artikel' ist weder Basis noch Element c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_moebel.cpp 7</p>
</blockquote>
<p>Wohl etwas zuviel umstrukturiert. Du hast die Basis &quot;wegoptimiert&quot;.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929029</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 09:50:21 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 10:11:05 GMT]]></title><description><![CDATA[<pre><code>#ifndef HEADER_NAME_H
#define HEADER_NAME_H

...

#endif
</code></pre>
<p>sowas änliches hab ich schonmal gesehen aber wie genau setze ich das ein?<br />
einfach header_name_h durch zb ICEAH_Artikel.h austauschen und damit die .h datei &quot;umklammern&quot; ?</p>
<blockquote>
<p>Wohl etwas zuviel umstrukturiert. Du hast die Basis &quot;wegoptimiert&quot;.</p>
</blockquote>
<p>ja, wegoptimiert find ich gut! nur wie stelle ich solch eine basisklasse wieder her, ich dachte bei c++ kann man klassen einfahc implementieren, hab doch vorher auch nciht gesagt &quot;so das ist jetzt ne basisiklasse&quot;</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929048</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 10:11:05 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 10:21:29 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<pre><code>#ifndef HEADER_NAME_H
#define HEADER_NAME_H

...

#endif
</code></pre>
<p>sowas änliches hab ich schonmal gesehen aber wie genau setze ich das ein?<br />
einfach header_name_h durch zb ICEAH_Artikel.h austauschen und damit die .h datei &quot;umklammern&quot; ?</p>
</blockquote>
<p>Genau.</p>
<p>Rustyspoon schrieb:</p>
<blockquote>
<blockquote>
<p>Wohl etwas zuviel umstrukturiert. Du hast die Basis &quot;wegoptimiert&quot;.</p>
</blockquote>
<p>ja, wegoptimiert find ich gut! nur wie stelle ich solch eine basisklasse wieder her, ich dachte bei c++ kann man klassen einfahc implementieren, hab doch vorher auch nciht gesagt &quot;so das ist jetzt ne basisiklasse&quot;</p>
<p>Gruß</p>
</blockquote>
<p>Äh, warum nicht so, wie in Deinem ersten Beispiel?</p>
<pre><code class="language-cpp">class ICEAH_Moebel : public ICEAH_Artikel{
</code></pre>
<p>Das geht in Headerdateien genauso.</p>
<p>Einer Klasse sagt man nicht: Du bist jetzt 'ne Basisklasse. Eine Klasse wird zu einer Basisklasse in dem Du der abgeleiteten Klasse sagt, Deine Basisklasse ist xyz.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929056</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929056</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 10:21:29 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 10:26:33 GMT]]></title><description><![CDATA[<pre><code>class ICEAH_Moebel : public ICEAH_Artikel{
....
</code></pre>
<p>so steht schon in meiner moebel.h hatte ich wohl mitlerweile selber gefunden.</p>
<p>aber hab noch 2 fehler:</p>
<p>Fehler 2 error C2504: 'ICEAH_Artikel': Basisklasse undefiniert c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_moebel.h 7<br />
Fehler 1 error C2011: 'ICEAH_Artikel': 'class' Typneudefinition c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_artikel.h 4</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929060</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 10:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 10:36:24 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<pre><code>class ICEAH_Moebel : public ICEAH_Artikel{
....
</code></pre>
<p>so steht schon in meiner moebel.h hatte ich wohl mitlerweile selber gefunden.</p>
<p>aber hab noch 2 fehler:</p>
<p>Fehler 2 error C2504: 'ICEAH_Artikel': Basisklasse undefiniert c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_moebel.h 7</p>
</blockquote>
<p>lass mal das</p>
<pre><code class="language-cpp">using namespace std;
</code></pre>
<p>weg und schreibe dafür statt string std:string. Ich bin mir jetzt nicht sicher, aber das könnte die Ursache sein, wenn Dein Quelltext wirklich so ausschaut, wie Du's hier gepostet hast.</p>
<p>Rustyspoon schrieb:</p>
<blockquote>
<p>Fehler 1 error C2011: 'ICEAH_Artikel': 'class' Typneudefinition c:\dokumente und einstellungen\tim\eigene dateien\visual studio 2008\projects\aufgabenueberarbeitet\uebung 11\iceah_artikel.h 4</p>
</blockquote>
<p>Hast Du meinen Tipp mit</p>
<pre><code class="language-cpp">#ifndef xxx
#define xxx
...
#endif
</code></pre>
<p>auch brav umgesetzt? Sorge auch dafür, daß das Makro eindeutig ist.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929067</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929067</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 10:36:24 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 12:45:48 GMT]]></title><description><![CDATA[<p>das using namespace std hat nichts veränder.</p>
<p>durch das define sind neue fehler aufgetreten.</p>
<p>ich poste nochmal den jetzigen code</p>
<p>iceah_moebel.h</p>
<pre><code>#ifndef ICEAH_Moebel_h
#define ICEAH_Moebel_h
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;

class ICEAH_Moebel : public ICEAH_Artikel{
public:
	std::string LangeBeschreibung();
	ICEAH_Moebel() ;
};
#endif
</code></pre>
<p>iceah_artikel.h</p>
<pre><code>#ifndef ICEAH_Artikel_h
#define ICEAH_Artikel_h
#include &lt;iostream&gt;
#include &lt;string&gt;

class ICEAH_Artikel{
public:
	static int count;
	std::string name;
	std::string beschreibung;
	virtual std::string LangeBeschreibung();
	ICEAH_Artikel();
};
#endif
</code></pre>
<p>iceah moebel.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Moebel.h&quot;

std::string ICEAH_Moebel::LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel::ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
</code></pre>
<p>iceah artikel.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Artikel.h&quot;
ICEAH_Artikel::ICEAH_Artikel(){
		count++;
}
int ICEAH_Artikel::count = 0; 
 std::string ICEAH_Artikel::LangeBeschreibung(){
return &quot;schalala&quot;;
}
</code></pre>
<p>main</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
#include &quot;ICEAH_Moebel.h&quot;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
//	ICEAH_Moebel IM;
	return 0;
}
</code></pre>
<p>edit:<br />
achja, hier die eigentliche aufgabe, falls es jemanden interessiert</p>
<blockquote>
<p>Aufgabe 1<br />
Folgende Punkte sollen zunächst umgesetzt werden:<br />
a) Entwurf einer abstrakten Basisklasse ICEAH_Artikel mit zwei Attributen Name und<br />
Beschreibung (z.B. Name “AOSELE“, Beschreibung „Tischleuchte“). Zusätzlich soll<br />
diese Klasse in einer statischen Variable Anzahl mitzählen, wie viele Objekte gerade<br />
existieren. Zur ausführlichen Beschreibung spendieren Sie noch eine rein virtuelle<br />
Funktion LangeBeschreibung, die in abgeleiteten Klassen implementiert werden soll.<br />
b) Entwurf zweier von der Basisklasse ICEAH_Artikel abgeleiteten Klassen:<br />
ICEAH_Moebel und ICEAH_Zubehoer. Artikel, deren Beschreibung „Stuhl“, „Tisch“<br />
oder „Schrank“ enthält, sollen (in Aufgabe 2) durch Objekte der Möbelklasse<br />
repräsentiert werden. Die Zubehörklasse repräsentiert alle anderen Artikel. Ebenfalls<br />
sollen diese Klassen in statischen Variablen mitzählen, wie viele Objekte jeweils gerade<br />
existieren.</p>
</blockquote>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929121</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929121</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 12:45:48 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 12:33:56 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>das using namespace std hat nichts veränder.</p>
<p>durch das define sind neue fehler aufgetreten.</p>
</blockquote>
<p>Schreibe statt</p>
<p>#ifndef ICEAH_Moebel.h<br />
#define ICEAH_Moebel.h</p>
<p>#ifndef ICEAH_Moebel**<em><strong>h<br />
#define ICEAH_Moebel</strong></em>**h</p>
<p>Punkte sind auch bei Makros nicht erlaubt.</p>
<p>Rustyspoon schrieb:</p>
<blockquote>
<p>ich poste nochmal den jetzigen code</p>
<p>iceah_moebel.h</p>
<pre><code>#ifndef ICEAH_Moebel.h
#define ICEAH_Moebel.h
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;

class ICEAH_Moebel : public ICEAH_Artikel{
public:
	std::string LangeBeschreibung();
	ICEAH_Moebel() ;
};
#endif
</code></pre>
<p>iceah_artikel.h</p>
<pre><code>#ifndef ICEAH_Artikel.h
#define ICEAH_Artikel.h
#include &lt;iostream&gt;
#include &lt;string&gt;

class ICEAH_Artikel{
public:
	static int count;
	std::string name;
	std::string beschreibung;
	virtual std::string LangeBeschreibung();
	ICEAH_Artikel();
};
#endif
</code></pre>
<p>iceah moebel.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Moebel.h&quot;

std::string ICEAH_Moebel::LangeBeschreibung(){
	return &quot;blablalba&quot;;
	}
	ICEAH_Moebel::ICEAH_Moebel() : ICEAH_Artikel(){
		//ICEAH_Artikel::count++;
	}
</code></pre>
<p>iceah artikel.cpp</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &quot;ICEAH_Artikel.h&quot;
ICEAH_Artikel::ICEAH_Artikel(){
		count++;
}
int ICEAH_Artikel::count = 0;
</code></pre>
<p>main</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
#include &quot;ICEAH_Artikel.h&quot;
#include &quot;ICEAH_Moebel.h&quot;
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
//	ICEAH_Moebel IM;
	return 0;
}
</code></pre>
</blockquote>
<p>Du hast immer noch keine Definition von</p>
<p>ICEAH_Artikel::LangeBeschreibung</p>
<p>Du mußt das schon Umsetzen, was Dir gesagt wird.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929133</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929133</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 12:33:56 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 12:49:39 GMT]]></title><description><![CDATA[<p>ahh danke!</p>
<p>jetzt copiliert der code. ich hab in meinem vorgangenen post mal meine code einträge soweit editiert wie ich es in echt gemacht habe.<br />
Was ich nicht genau verstehe ist, warum ich die abstrakte Funktion deklarieren muss?<br />
Ist das nicht das was ich garnicht will?<br />
ich meine Artikel hat kein genaue Beschreibung. Erst das moebelstück hat eine. Welches ja artikel ableitet?</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929145</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929145</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 12:49:39 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 13:06:19 GMT]]></title><description><![CDATA[<p>Rustyspoon schrieb:</p>
<blockquote>
<p>ahh danke!</p>
<p>jetzt copiliert der code.</p>
</blockquote>
<p>Na bitte. Geht doch. <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="👍"
    /></p>
<p>Rustyspoon schrieb:</p>
<blockquote>
<p>ich hab in meinem vorgangenen post mal meine code einträge soweit editiert wie ich es in echt gemacht habe.<br />
Was ich nicht genau verstehe ist, warum ich die abstrakte Funktion deklarieren muss?<br />
Ist das nicht das was ich garnicht will?<br />
ich meine Artikel hat kein genaue Beschreibung. Erst das moebelstück hat eine. Welches ja artikel ableitet?</p>
<p>Gruß</p>
</blockquote>
<p>Nun in Deiner konkreten Anwendung ist es wohl nicht erforderlich. Aber es ist so gefordert in der Aufgabenstellung. Allerdings ist es blöd formuliert. Was die mit &quot;rein virtuell&quot; meinten ist wohl, daß Du eine abstrakte Klasse definieren sollst. Damit kannst Du die Basisklasse nicht selbst instanzieren kannst aber trotzdem mit Zeigern darauf Memberfunktionen der abgeleiteten Klassen aufrufen:</p>
<pre><code class="language-cpp">class base
{
   virtual function() = 0;
}

class derived : public base
{
   function();
}

int derived::function()
{
   return 5;
}

int main( void )
{
   base *x = new derived;

   cout &lt;&lt; x-&gt;function();

   delete x;

   return 0;
}
</code></pre>
<p>function ist in base nur deklariert nicht aber definiert. Und weil es abstrakt ist, darfst Du auch keine Instanz von base erzeugen:</p>
<pre><code class="language-cpp">base x;
</code></pre>
<p>gibt einen Compilerfehler.</p>
<p>Weil es aber virtuel ist, kannst Du es trotzdem über einen Zeige auf base aufrufen. Deine Anwendung entscheidet dann zur Laufzeit was aufgerufen werden soll.</p>
<p>Bei diesem einfachen Beispiel ist es natürlich dumm. Aber stelle Dir mal vor Du schreibst eine Containerklasse, die verschiedene Zeiger speichern soll und über diese Zeiger bestimmte Methoden aufrufen soll. Der Container kennt aber unter Umständen nur die Basisklasse. Möglicherweise definiert die Basisklasse nur das Interface. Der Programmierer des Containers soll sich aber nicht mit der Implementierung der Memberfunktionen beschäftgen.</p>
<p>Dazu definiert er eine abstrakte Klasse, die alle erforderlichen Funktionen kennt und gibt seinen Kolegen nur den Container und die Basisklasse. Die Kolegen erzeugen dann neue Klassen, die von der Basis abgeleitet sind, und übergeben dem Container Zeiger auf diese Klassen.</p>
<p>mfg Martin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929157</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929157</guid><dc:creator><![CDATA[mgaeckler]]></dc:creator><pubDate>Tue, 20 Jul 2010 13:06:19 GMT</pubDate></item><item><title><![CDATA[Reply to vererbung[gelöst] on Tue, 20 Jul 2010 14:38:32 GMT]]></title><description><![CDATA[<p>sauber!</p>
<p>ich denke mal ich habs verstanden, echt top was du dir für ne mühe gegeben hast!</p>
<p>Gruß</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1929206</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1929206</guid><dc:creator><![CDATA[Rustyspoon]]></dc:creator><pubDate>Tue, 20 Jul 2010 14:38:32 GMT</pubDate></item></channel></rss>