<?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[Compile-Warnung: Direct base is inaccessible]]></title><description><![CDATA[<p>Hallo,<br />
wenn ich folgendes Konstrukt habe, bekomme ich eine Warnung vom <strong>gcc</strong></p>
<pre><code class="language-cpp">class A
{
public:
  virtual int getSomeValue() const = 0;
  ...

  A();
  virtual ~A();
  bool operator==(A const&amp; a) const;
  bool operator!=(A const&amp; a) const;

private:
  A(A const&amp; a);
  A&amp; operator=(A const&amp; a);
};

class B : public A
{
public:
  int getSomeValue() const;
  void setSomeValue(int value);

  B();
  virtual ~B();
  B&amp; operator=(B const&amp; b);
  bool operator==(B const&amp; b) const;
  bool operator!=(B const&amp; b) const;
protected:
  virtual void someValueChanged(int value) = 0;
private:
  int m_someValue;
};

class C : public A, private B
{
  virtual int getSomeValue() const; //Ruft die Funktion von B auf

  C();
  C(C const&amp; c);
  virtual ~C();

  C&amp; operator=(C const&amp; c);
  bool operator==(C const&amp; c);
  bool operator!=(C const&amp; c);

protected:
  virtual void someValueChanged(int value) = 0;
};
</code></pre>
<p>Bekomme ich den Fehler:<br />
<strong>warning: direct base A inaccessible in C due to ambiguity</strong></p>
<p>leider kann ich mit der Warunung nichts anfangen. Ziel soll es sein, dass nach außen nur die abstrakte (schreibgeschützte) Klasse A zugreifbar sein. Intern allerdings B. Jede abgeleitete Klasse (Filter) sollen anschließend von C erben. C hat nur die Aufgabe, Schreibarbeit zu minimieren, um alle Funktionen von A auf die private Klasse B zuweisen, mit der Absicht, dass die Funktionen auch überschrieben werden können. Hoffe ihr könnt mir helfen. Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/211316/compile-warnung-direct-base-is-inaccessible</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 00:08:13 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/211316.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 21 Apr 2008 18:30:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compile-Warnung: Direct base is inaccessible on Mon, 21 Apr 2008 18:30:39 GMT]]></title><description><![CDATA[<p>Hallo,<br />
wenn ich folgendes Konstrukt habe, bekomme ich eine Warnung vom <strong>gcc</strong></p>
<pre><code class="language-cpp">class A
{
public:
  virtual int getSomeValue() const = 0;
  ...

  A();
  virtual ~A();
  bool operator==(A const&amp; a) const;
  bool operator!=(A const&amp; a) const;

private:
  A(A const&amp; a);
  A&amp; operator=(A const&amp; a);
};

class B : public A
{
public:
  int getSomeValue() const;
  void setSomeValue(int value);

  B();
  virtual ~B();
  B&amp; operator=(B const&amp; b);
  bool operator==(B const&amp; b) const;
  bool operator!=(B const&amp; b) const;
protected:
  virtual void someValueChanged(int value) = 0;
private:
  int m_someValue;
};

class C : public A, private B
{
  virtual int getSomeValue() const; //Ruft die Funktion von B auf

  C();
  C(C const&amp; c);
  virtual ~C();

  C&amp; operator=(C const&amp; c);
  bool operator==(C const&amp; c);
  bool operator!=(C const&amp; c);

protected:
  virtual void someValueChanged(int value) = 0;
};
</code></pre>
<p>Bekomme ich den Fehler:<br />
<strong>warning: direct base A inaccessible in C due to ambiguity</strong></p>
<p>leider kann ich mit der Warunung nichts anfangen. Ziel soll es sein, dass nach außen nur die abstrakte (schreibgeschützte) Klasse A zugreifbar sein. Intern allerdings B. Jede abgeleitete Klasse (Filter) sollen anschließend von C erben. C hat nur die Aufgabe, Schreibarbeit zu minimieren, um alle Funktionen von A auf die private Klasse B zuweisen, mit der Absicht, dass die Funktionen auch überschrieben werden können. Hoffe ihr könnt mir helfen. Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1495823</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1495823</guid><dc:creator><![CDATA[kleines_eichhoernchen]]></dc:creator><pubDate>Mon, 21 Apr 2008 18:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to Compile-Warnung: Direct base is inaccessible on Mon, 21 Apr 2008 18:46:38 GMT]]></title><description><![CDATA[<p>Du hast bei C zweimal von A geerbt. Einmal direkt, einmal indirekt über B. Da Du so in C einige Symbole mehrfach definiert hast, kommt es zu dem Fehler.<br />
Schau mal, was virtuelle Vererbung ist. Das sollte helfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1495835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1495835</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Mon, 21 Apr 2008 18:46:38 GMT</pubDate></item><item><title><![CDATA[Reply to Compile-Warnung: Direct base is inaccessible on Wed, 23 Apr 2008 05:54:09 GMT]]></title><description><![CDATA[<p>was virtuelle Vererbung ist weiß ich. Ich habe das jetzt so gelöst, dass das Interface nur ReadOnly-Funktionen hat, die abgeleiteten Klassen aber auch Funktionen zum Ändern haben. Nach draußen wird nur ein shared_boost&lt;A&gt; gegeben. Mit einer map intern werden die abgeleiteten Klassen gespeichert (angesprochen über ID). Bin da leider aber noch nicht ganz zufrieden mit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1496578</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1496578</guid><dc:creator><![CDATA[kleines_eichhoernchen]]></dc:creator><pubDate>Wed, 23 Apr 2008 05:54:09 GMT</pubDate></item></channel></rss>