<?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[include und Vererbung in Dreiecksbeziehung]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe ein Problem, dass ich auf ein Beispielprogramm von 3 Klassen runtergebrochen habe. Leider erkenne ich nicht, woran das Kompilieren hier scheitert. Kann mir jemand weiterhelfen?</p>
<pre><code class="language-cpp">#ifndef A_HPP
#define A_HPP
#include &quot;c.hpp&quot;
#include &quot;b.hpp&quot;

class c;
class b;

class a
{
public:
    a(){} ;
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef C_HPP
#define C_HPP

#include &quot;a.hpp&quot;

class a;

class c {
public:
    c(){};
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef B_HPP
#define B_HPP

class c;

class b: public c {
public:
    b(){};
};
#endif
</code></pre>
<p>Die Fehlermeldungen lauten immer etwas anderes, jenachdem, wie ich das Problem zu lösen versuche. Wenn ich das richtig verstehe, ist die gemeinsame Basis aber immer, dass die Klasse b nicht von c erben kann, da c nur als struct verstanden wird:</p>
<blockquote>
<p>../src/b.hpp:6: error: invalid use of incomplete type ‘struct c’<br />
../src/b.hpp:4: error: forward declaration of ‘struct c’</p>
</blockquote>
<p>Grüße, dulle</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/276290/include-und-vererbung-in-dreiecksbeziehung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 26 Aug 2026 11:06:06 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/276290.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 Oct 2010 12:59:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 12:59:49 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>ich habe ein Problem, dass ich auf ein Beispielprogramm von 3 Klassen runtergebrochen habe. Leider erkenne ich nicht, woran das Kompilieren hier scheitert. Kann mir jemand weiterhelfen?</p>
<pre><code class="language-cpp">#ifndef A_HPP
#define A_HPP
#include &quot;c.hpp&quot;
#include &quot;b.hpp&quot;

class c;
class b;

class a
{
public:
    a(){} ;
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef C_HPP
#define C_HPP

#include &quot;a.hpp&quot;

class a;

class c {
public:
    c(){};
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef B_HPP
#define B_HPP

class c;

class b: public c {
public:
    b(){};
};
#endif
</code></pre>
<p>Die Fehlermeldungen lauten immer etwas anderes, jenachdem, wie ich das Problem zu lösen versuche. Wenn ich das richtig verstehe, ist die gemeinsame Basis aber immer, dass die Klasse b nicht von c erben kann, da c nur als struct verstanden wird:</p>
<blockquote>
<p>../src/b.hpp:6: error: invalid use of incomplete type ‘struct c’<br />
../src/b.hpp:4: error: forward declaration of ‘struct c’</p>
</blockquote>
<p>Grüße, dulle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1972681</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972681</guid><dc:creator><![CDATA[dulle]]></dc:creator><pubDate>Sat, 30 Oct 2010 12:59:49 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 13:55:21 GMT]]></title><description><![CDATA[<p>Bei mir erstellt er deinen Code mittels include a.hpp in der main. Aber versuchs mal so:</p>
<pre><code class="language-cpp">#ifndef A_HPP
#define A_HPP
#include &quot;c.hpp&quot;
#include &quot;b.hpp&quot;

class c;
class b;

class a
{
public:
    a(){} ;
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef C_HPP
#define C_HPP

class a; // &lt;----

class c {
public:
    c(){};
};
#endif
</code></pre>
<pre><code class="language-cpp">#ifndef B_HPP
#define B_HPP

#include &quot;c.hpp&quot; // &lt;----

class b: public c {
public:
    b(){};
};
#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1972698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972698</guid><dc:creator><![CDATA[HighLigerBiMBam]]></dc:creator><pubDate>Sat, 30 Oct 2010 13:55:21 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 16:14:19 GMT]]></title><description><![CDATA[<p>Vermutlich musst du eine Klasse mitsamt Funktionen und Variablen deklarieren (also nicht bloß class c;), bevor du davon erben kannst. Sonst wäre nämlich eine im-Kreis-Vererbung möglich (a erbt von c, b erbt von a und c erbt von b).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1972701</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972701</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Sat, 30 Oct 2010 16:14:19 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 14:07:47 GMT]]></title><description><![CDATA[<blockquote>
<p>Vermutlich musst du eine Klasse mitsamt Funktionen und Variablen deklarieren (also nicht bloß class c, bevor du davon erben kannst.</p>
</blockquote>
<p>Ja, das ist korrekt. Nennt man aber Klasse definieren, nicht deklarieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1972705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972705</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Sat, 30 Oct 2010 14:07:47 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 15:58:05 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/24205">@HighLigerBiMBam</a>: Danke dir, die Lösung funktioniert, nach Beseitigung ein paar weiterer Compiler-Fehler auch in meinem größeren Programm.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/23670">@wxSkip</a> und theta: okay, mir war nicht bewusst, dass das ein Problem darstellen kann keine Variablen und/oder Funktionen definiert zu haben, aber in meinem eigentlichen Programm habe ich natürlich genauer definierte Klassen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1972751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972751</guid><dc:creator><![CDATA[dulle]]></dc:creator><pubDate>Sat, 30 Oct 2010 15:58:05 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 16:13:43 GMT]]></title><description><![CDATA[<p>dulle schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/24205">@HighLigerBiMBam</a>: Danke dir, die Lösung funktioniert, nach Beseitigung ein paar weiterer Compiler-Fehler auch in meinem größeren Programm.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/23670">@wxSkip</a> und theta: okay, mir war nicht bewusst, dass das ein Problem darstellen kann keine Variablen und/oder Funktionen definiert zu haben, aber in meinem eigentlichen Programm habe ich natürlich genauer definierte Klassen.</p>
</blockquote>
<p>Ich weiß nicht, ob du verstanden hast, was wir gemeint haben (das ist nämlich das, was HighLigerBiMBam gemacht hat):</p>
<pre><code class="language-cpp">//so geht es nicht:

class A;

class B : public A
{
    //blah
}

class A
{
    //blah
}
</code></pre>
<pre><code class="language-cpp">//und so geht es:

class A
{
    //blah
}

class B : public A
{
    //blah
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1972758</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972758</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Sat, 30 Oct 2010 16:13:43 GMT</pubDate></item><item><title><![CDATA[Reply to include und Vererbung in Dreiecksbeziehung on Sat, 30 Oct 2010 17:14:52 GMT]]></title><description><![CDATA[<p>Lies mal das <a href="http://www.drakon.ch/?id=&amp;offset=5&amp;mobile=0&amp;show_entry=77" rel="nofollow">hier.</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1972779</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1972779</guid><dc:creator><![CDATA[drakon]]></dc:creator><pubDate>Sat, 30 Oct 2010 17:14:52 GMT</pubDate></item></channel></rss>