<?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[&amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot;]]></title><description><![CDATA[<p>Guten Morgen allerseits,</p>
<p>ich beschäftige mich grade etwas mit Vererbung und dergleichen. Ich habe eine Klasse Steuerung, diese ist wiefolgt aufgebaut:</p>
<pre><code class="language-cpp">namespace Test
{
class Steuerung 
{
public:

    virtual int Init(const ::std::string&amp;) = 0;

    virtual bool IsMotorRunning(int) = 0;

    virtual bool Stop(int) = 0;

    virtual bool GotoMM(int, float) = 0;
};
}
</code></pre>
<p>Jetzt möchte ich eine Klasse TestI davon ableiten.</p>
<p>In der Klasse testI.h habe ich folgendes:</p>
<pre><code class="language-cpp">#ifndef TEST_I_H
#define TEST_I_H

#include &quot;test.h&quot;
#include &lt;iostream&gt;

class TestI : public Test::Steuerung
{
public:
	virtual int Init(std::string devname);
	virtual bool IsMotorRunning(int aMotorNum);
	virtual bool Stop(int aMotorNum);
	virtual bool GotoMM(int aMotorNum, float aPositionMM);
};

#endif
</code></pre>
<p>und in der testI.cpp</p>
<pre><code class="language-cpp">#include &quot;testI.h&quot;
#include &lt;iostream&gt;

using namespace std;

int TestI::Init(string devname){
	cout &lt;&lt; &quot;Init with &quot; &lt;&lt; devname &lt;&lt; endl;
	return 0;
}

bool TestI::IsMotorRunning(int aMotorNum){
	cout &lt;&lt; &quot;IsMotorRunning with &quot; &lt;&lt; aMotorNum &lt;&lt; endl;
	return true;
}

bool TestI::Stop(int aMotorNum){
	cout &lt;&lt; &quot;Stop with &quot; &lt;&lt; aMotorNum &lt;&lt; endl;
	return true;
}
bool TestI::GotoMM(int aMotorNum, float aPositionMM){
	cout &lt;&lt; &quot;GotoMM with &quot; &lt;&lt; aMotorNum &lt;&lt; &quot; and &quot; &lt;&lt; aPositionMM &lt;&lt; endl;
	return true;
}
</code></pre>
<p>wenn ich nun aber ein Objekt von TestI erstellen will sagt er mir folgendes:</p>
<p><strong>The type 'TestI' must implement the inherited pure virtual method 'Test::Steuerung::Stop'.</strong></p>
<p>Ich dachte aber eigentlich, dass ich die Methode Stop ja schon eingebaut habe.<br />
Die test.h Datei ist mit ihren Namespaces so vorgegeben.</p>
<p>Ich frage mich jetzt gerade, wie ich den Fehler beheben kann.</p>
<p>viele Grüße<br />
Salva</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/291985/quot-the-type-testi-must-implement-the-inherited-pure-virtual-method-quot</link><generator>RSS for Node</generator><lastBuildDate>Mon, 17 Aug 2026 08:32:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/291985.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 31 Aug 2011 14:27:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot; on Wed, 31 Aug 2011 14:50:18 GMT]]></title><description><![CDATA[<p>Guten Morgen allerseits,</p>
<p>ich beschäftige mich grade etwas mit Vererbung und dergleichen. Ich habe eine Klasse Steuerung, diese ist wiefolgt aufgebaut:</p>
<pre><code class="language-cpp">namespace Test
{
class Steuerung 
{
public:

    virtual int Init(const ::std::string&amp;) = 0;

    virtual bool IsMotorRunning(int) = 0;

    virtual bool Stop(int) = 0;

    virtual bool GotoMM(int, float) = 0;
};
}
</code></pre>
<p>Jetzt möchte ich eine Klasse TestI davon ableiten.</p>
<p>In der Klasse testI.h habe ich folgendes:</p>
<pre><code class="language-cpp">#ifndef TEST_I_H
#define TEST_I_H

#include &quot;test.h&quot;
#include &lt;iostream&gt;

class TestI : public Test::Steuerung
{
public:
	virtual int Init(std::string devname);
	virtual bool IsMotorRunning(int aMotorNum);
	virtual bool Stop(int aMotorNum);
	virtual bool GotoMM(int aMotorNum, float aPositionMM);
};

#endif
</code></pre>
<p>und in der testI.cpp</p>
<pre><code class="language-cpp">#include &quot;testI.h&quot;
#include &lt;iostream&gt;

using namespace std;

int TestI::Init(string devname){
	cout &lt;&lt; &quot;Init with &quot; &lt;&lt; devname &lt;&lt; endl;
	return 0;
}

bool TestI::IsMotorRunning(int aMotorNum){
	cout &lt;&lt; &quot;IsMotorRunning with &quot; &lt;&lt; aMotorNum &lt;&lt; endl;
	return true;
}

bool TestI::Stop(int aMotorNum){
	cout &lt;&lt; &quot;Stop with &quot; &lt;&lt; aMotorNum &lt;&lt; endl;
	return true;
}
bool TestI::GotoMM(int aMotorNum, float aPositionMM){
	cout &lt;&lt; &quot;GotoMM with &quot; &lt;&lt; aMotorNum &lt;&lt; &quot; and &quot; &lt;&lt; aPositionMM &lt;&lt; endl;
	return true;
}
</code></pre>
<p>wenn ich nun aber ein Objekt von TestI erstellen will sagt er mir folgendes:</p>
<p><strong>The type 'TestI' must implement the inherited pure virtual method 'Test::Steuerung::Stop'.</strong></p>
<p>Ich dachte aber eigentlich, dass ich die Methode Stop ja schon eingebaut habe.<br />
Die test.h Datei ist mit ihren Namespaces so vorgegeben.</p>
<p>Ich frage mich jetzt gerade, wie ich den Fehler beheben kann.</p>
<p>viele Grüße<br />
Salva</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2113006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2113006</guid><dc:creator><![CDATA[Salva]]></dc:creator><pubDate>Wed, 31 Aug 2011 14:50:18 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot; on Wed, 31 Aug 2011 14:38:16 GMT]]></title><description><![CDATA[<p>Ich nehme mal an, dass der erste Codeblock so aussehen sollte:</p>
<pre><code class="language-cpp">namespace Test
{
  class Steuerung
  {
  public:

    virtual int Init(const ::std::string&amp;) = 0;

    virtual bool IsMotorRunning(int) = 0;

    virtual bool Stop(int) = 0;

    virtual bool GotoMM(int, float) = 0;
  }; 
}
</code></pre>
<p>Richtig?</p>
<p>Zwei Fehler die ich sehe:<br />
Du hast Stop zweimal definiert. Das kann nicht gehen.<br />
Die Argumente von Steuerung.Init und TestI.init sind unterschiedlich. Dadurch bleibt Init(const ::std::string&amp;) in TestI weiterhin abstrakt.</p>
<p>Wie das aber zu der gezeigten Fehlermeldung führen kann ist rätselhaft.</p>
<p>P.S.: Und deine Init-Methode ist hoffentlich kein Konstruktorersatz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2113020</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2113020</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 31 Aug 2011 14:38:16 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot; on Wed, 31 Aug 2011 14:48:45 GMT]]></title><description><![CDATA[<p>oh ja, das const vom anfang ist eigentlich weg, sorry. Das war noch aus einer vorherigen Version.</p>
<p>Das 2. Stop hatte ich geschrieben um zu testen, welche er mir im Namespace TestI alle anzeigt.</p>
<p>Richtig, Steuerung liegt im namespace Test.</p>
<p>Die Steuerung Klasse ist wie gesagt vorgegeben und auch noch etwas komplexer, die kann ich auch nicht verändern. (Nein es ist keine Hausaufgabe oder sonst was <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> )</p>
<p>Danke für die Mühe</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2113029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2113029</guid><dc:creator><![CDATA[Salva]]></dc:creator><pubDate>Wed, 31 Aug 2011 14:48:45 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot; on Wed, 31 Aug 2011 14:52:02 GMT]]></title><description><![CDATA[<p>Könntest du dann mal versuchen, den Code soweit wie möglich zu kürzen und dann hier 1:1 die letzte Version zeigen, die den Fehler noch erzeugt? Vielleicht findest du dabei auch selber schon den Fehler.<br />
Wenn ich nämlich die zwei von mir genannten Sachen korrigiere, funktioniert es. Und selbst wenn ich es nicht tue sind die Fehler, wie schon gesagt, ganz andere.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2113030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2113030</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 31 Aug 2011 14:52:02 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;The type &#x27;TestI&#x27; must implement the inherited pure virtual method&amp;quot; on Wed, 31 Aug 2011 19:23:24 GMT]]></title><description><![CDATA[<p>Und: Test::Steuerung sollte einen virtuellen Destruktor bereitstellen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2113173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2113173</guid><dc:creator><![CDATA[wxSkip]]></dc:creator><pubDate>Wed, 31 Aug 2011 19:23:24 GMT</pubDate></item></channel></rss>