<?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[Unbekannter Rückgabewert in Interface-Klasse]]></title><description><![CDATA[<p>Wie kann man bei einer abstrakten Interface-Klasse den Rückgabewert einer Methode definieren, der erst in der abgeleiteten Klasse bekannt ist?</p>
<p>Beispiel:</p>
<pre><code class="language-cpp">class Interface
{
public:
  virtual UnknownType* getInternalType() = 0;
}

class A : public Interface
{
private:
  B *internal_type_;

public:
  virtual B* getInternalType()
}
</code></pre>
<p>Bei diesem Beispiel kommt eine Fehlermeldung vom Compiler:<br />
overriding virtual function return type differs and is not covariant from 'Interface::getInternalType'</p>
<p>Danke für Hinweise!</p>
<p>Gruß,<br />
Lemmy</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182688/unbekannter-rückgabewert-in-interface-klasse</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 00:09:12 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182688.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 May 2007 08:40:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 08:40:52 GMT]]></title><description><![CDATA[<p>Wie kann man bei einer abstrakten Interface-Klasse den Rückgabewert einer Methode definieren, der erst in der abgeleiteten Klasse bekannt ist?</p>
<p>Beispiel:</p>
<pre><code class="language-cpp">class Interface
{
public:
  virtual UnknownType* getInternalType() = 0;
}

class A : public Interface
{
private:
  B *internal_type_;

public:
  virtual B* getInternalType()
}
</code></pre>
<p>Bei diesem Beispiel kommt eine Fehlermeldung vom Compiler:<br />
overriding virtual function return type differs and is not covariant from 'Interface::getInternalType'</p>
<p>Danke für Hinweise!</p>
<p>Gruß,<br />
Lemmy</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293495</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 08:40:52 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 08:44:33 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich habe keine genaue Ahnugn, aber tippe mal, das so etwas entweder mit den verpönnten void-eigern oder mit templates geht.</p>
<p>chrische</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293502</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Mon, 28 May 2007 08:44:33 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:06:32 GMT]]></title><description><![CDATA[<p>Ich fürchte Templates helfen mir hier nicht wirklich weiter.<br />
Gibt es vl. noch eine andere Möglichkeit?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293525</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293525</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:06:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:09:32 GMT]]></title><description><![CDATA[<p>Wie wärs, wenn alle Rückgabetypen(klassen?) von einer Basisklasse ableiten?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293526</guid><dc:creator><![CDATA[PyradmieAusÄgypten]]></dc:creator><pubDate>Mon, 28 May 2007 09:09:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:14:47 GMT]]></title><description><![CDATA[<p>Sinn?</p>
<p>Was willst du mit dem Interface erreichen, wenn man wissen muss, welche Abgeleitete Klasse da instantiirt ist?</p>
<p>Der Sinn von polymorphismus/interfaces ist doch, dass du die Interfaces benutzen kannst ohne die genaue Klasse zu kennen, die da instantiiert ist ...</p>
<p>Warum gehen keine Templates?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293528</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293528</guid><dc:creator><![CDATA[darthdespotism]]></dc:creator><pubDate>Mon, 28 May 2007 09:14:47 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:16:46 GMT]]></title><description><![CDATA[<p>Das ist wahrscheinlich nur mein Problem, aber was ist an deinem Typen &quot;Internal&quot;, wenn du einen öffentlichen Zugriff darauf erlaubst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293530</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 28 May 2007 09:16:46 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:18:27 GMT]]></title><description><![CDATA[<p>PyradmieAusÄgypten schrieb:</p>
<blockquote>
<p>Wie wärs, wenn alle Rückgabetypen(klassen?) von einer Basisklasse ableiten?</p>
</blockquote>
<p>Das will ich eigentlich vermeiden, weil die Rückgabetypen aus einer Lib kommen.</p>
<p>darthdespotism schrieb:</p>
<blockquote>
<p>Sinn?<br />
[...]<br />
Warum gehen keine Templates?</p>
</blockquote>
<p>Bei einem Template muss ich ja den genauen Typ angeben oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293531</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:20:43 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Das ist wahrscheinlich nur mein Problem, aber was ist an deinem Typen &quot;Internal&quot;, wenn du einen öffentlichen Zugriff darauf erlaubst?</p>
</blockquote>
<p>Der interne Typ ist der Datentyp, den die externen Lib-Funktionen benötigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293533</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293533</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:30:36 GMT]]></title><description><![CDATA[<p>Lemmy schrieb:</p>
<blockquote>
<p>camper schrieb:</p>
<blockquote>
<p>Das ist wahrscheinlich nur mein Problem, aber was ist an deinem Typen &quot;Internal&quot;, wenn du einen öffentlichen Zugriff darauf erlaubst?</p>
</blockquote>
<p>Der interne Typ ist der Datentyp, den die externen Lib-Funktionen benötigen.</p>
</blockquote>
<p>Könntest du ein Beispiel geben, wie das benutzt werden soll?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293540</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293540</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 28 May 2007 09:30:36 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:41:45 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Könntest du ein Beispiel geben, wie das benutzt werden soll?</p>
</blockquote>
<pre><code class="language-cpp">class Matrix
{
public:
  virtual UnknownMatrixType* getInternalType() = 0;
}

class LaMatrix : public Matrix
{
private:
  LaGenMatDouble *internal_type_;

public:
  virtual LaGenMatDouble* getInternalType()
}

class LaVector : public Matrix
{
private:
  LaVectorDouble *internal_type_;

public:
  virtual LaVectorDouble* getInternalType()
}
</code></pre>
<p>LaGenMatDouble und LaVectorDouble sind Lib-Klassen.</p>
<p>Und dann gibt es zB irgendwo folgende Methode:</p>
<pre><code class="language-cpp">void getMultiplication(Matrix&amp; A, Matrix&amp; B)
{
  libFunction(A-&gt;getInternalType, B-&gt;getInternalType);
}
</code></pre>
<p>Und je nachdem, ob es sich um einen Vektor oder eine Matrix handelt, sollte auch der interne Typ an libFunction übergeben werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293544</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293544</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:47:55 GMT]]></title><description><![CDATA[<p>Dann brauchst du Kovarianz gar nicht. Gibt einfach in allen Klassen ein UnknownType* zurück.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293548</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 28 May 2007 09:47:55 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:50:38 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Dann brauchst du Kovarianz gar nicht. Gibt einfach in allen Klassen ein UnknownType* zurück.</p>
</blockquote>
<p>Hm. UnknownType* hab i da jetzt nur so hingeschrieben, weil ich nicht weiß, was ich da als return-Wert zurückliefern soll. Also genau hier liegt mein Problem. Also die Klasse *UnknownType gibts gar nicht. Und irgendwas muss ich aber in der Basisklasse auch als Return-Wert zurückgeben, nur was?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293549</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:50:38 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:53:35 GMT]]></title><description><![CDATA[<p>UnknownType* ist ja nichts weiter als der Typ von<br />
A-&gt;getInternalType() bzw. B-&gt;getInternalType() in</p>
<pre><code class="language-cpp">libFunction(A-&gt;getInternalType(), B-&gt;getInternalType());
</code></pre>
<p>und richtet sich demzufolge nach dem Typen, den die Funktion verlangt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293551</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293551</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Mon, 28 May 2007 09:53:35 GMT</pubDate></item><item><title><![CDATA[Reply to Unbekannter Rückgabewert in Interface-Klasse on Mon, 28 May 2007 09:58:24 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>UnknownType* ist ja nichts weiter als der Typ von<br />
A-&gt;getInternalType() bzw. B-&gt;getInternalType() in</p>
<pre><code class="language-cpp">libFunction(A-&gt;getInternalType(), B-&gt;getInternalType());
</code></pre>
<p>und richtet sich demzufolge nach dem Typen, den die Funktion verlangt.</p>
</blockquote>
<p>Ja, aber hier kann sowohl<br />
- LaVectorDouble<br />
- LaGenMatDouble<br />
an die Lib-Funktion übergeben werden, d.h. ich hab 2 verschiedene Typen, wo ich aber nicht vorher nicht weiß, welcher wirklich daher kommt. Das sollte dann dynamisch eingesetzt werden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293557</guid><dc:creator><![CDATA[Lemmy]]></dc:creator><pubDate>Mon, 28 May 2007 09:58:24 GMT</pubDate></item></channel></rss>