<?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[g++: no matching function call to &#x27;...&#x27;]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>bin neu hier im Forum und möchte euch alle Grüßen:)<br />
Nun komme ich auch gleich mit einem Problem daher, dem ich einfach nicht Herr werde. Mir sind die Ideen ausgegangen und das Netz spuckt auch keine brauchbaren Hinweise aus.</p>
<p>Hier die Fehlermeldung vom g++:</p>
<pre><code>/home/hymir/Entwicklung/cxx/Projekte/TestQTstuff/testb.cpp:21: Fehler:no matching function for call to 'TestB::setField(int*&amp;, QPair&lt;int, int&gt;&amp;)'
  setField(this-&gt;y, pair);
                        ^
/home/hymir/Entwicklung/cxx/Projekte/TestQTstuff/testb.cpp:22: Fehler:no matching function for call to 'TestB::setField(int*&amp;, QPair&lt;int, int&gt;&amp;)'
  setField(this-&gt;x, pair);
                        ^
</code></pre>
<p>Und hier das passend Minimalbeispiel:<br />
(Datei testa.h)</p>
<pre><code>#include &lt;QPair&gt;

#ifndef TESTA_H
#define TESTA_H

class TestA
{
	public:
		TestA();
		virtual void fromPair(QPair&lt;int, int&gt;&amp; pair);
		int* getX();
		int* getY();
	protected:
		int* x;
		int* y;
		void setField(int* field, QPair&lt;int, int&gt;&amp; pair);
};

#endif // TESTA_H
</code></pre>
<p>(Datei testa.cpp)</p>
<pre><code>#include &quot;testa.h&quot;

TestA::TestA()
	:x(NULL),
		y(NULL)
{
}

void TestA::setField(int *field, QPair&lt;int, int&gt; &amp;pair)
{
	(*field) = pair.first * pair.second;
}

void TestA::fromPair(QPair&lt;int, int&gt; &amp;pair)
{
	setField(this-&gt;x, pair);
	setField(this-&gt;y, pair);
}

int* TestA::getY()
{
	return y;
}

int* TestA::getX()
{
	return x;
}
</code></pre>
<p>(Datei testb.h)</p>
<pre><code>#include &lt;QString&gt;
#include &quot;testa.h&quot;

#ifndef TESTB_H
#define TESTB_H

class TestB : public TestA
{
	public:
		TestB();
		void fromPair(QPair&lt;int, int&gt;&amp; pair);
		QString* getOrig(void);
	protected:
		QString* orig;
		void setField(QString*&amp; field, QPair&lt;int, int&gt; &amp;pair);
};

#endif // TESTB_H
</code></pre>
<p>(Datei testb.cpp)</p>
<pre><code>#include &quot;testb.h&quot;

TestB::TestB()
	:orig(NULL)
{
}

void TestB::setField(QString *&amp;field, QPair&lt;int, int&gt; &amp;pair)
{
	field = new QString();
	field-&gt;append('(');
	field-&gt;append(pair.first);
	field-&gt;append(&quot;, &quot;);
	field-&gt;append(pair.second);
	field-&gt;append(')');
}

void TestB::fromPair(QPair&lt;int, int&gt; &amp;pair)
{
	//TestA::fromPair(pair);
	setField(this-&gt;y, pair);
	setField(this-&gt;x, pair);
	setField(this-&gt;orig, pair);
}
</code></pre>
<p>In der main-funktion erstelle ich ein QPair objekt und ein TestB objekt.<br />
Danach rufe ich testbobjekt.fromPair(myPair) auf, das wars.<br />
Ich habe hier zwar QT Klassen verwendet, sollte aber nicht von Bedeutung sein, wenn man sie gegen irgendetwas anderes austauscht.</p>
<p>Der oben genannte Fehler sieht aus als wäre er ein typischer Fehler in C++.<br />
Bedanke mich herzlich im Voraus für eure Hilfe,<br />
Beste Grüße.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/323307/g-no-matching-function-call-to</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Jul 2026 06:51:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/323307.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Jan 2014 14:03:40 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 14:03:40 GMT]]></title><description><![CDATA[<p>Hi Leute,</p>
<p>bin neu hier im Forum und möchte euch alle Grüßen:)<br />
Nun komme ich auch gleich mit einem Problem daher, dem ich einfach nicht Herr werde. Mir sind die Ideen ausgegangen und das Netz spuckt auch keine brauchbaren Hinweise aus.</p>
<p>Hier die Fehlermeldung vom g++:</p>
<pre><code>/home/hymir/Entwicklung/cxx/Projekte/TestQTstuff/testb.cpp:21: Fehler:no matching function for call to 'TestB::setField(int*&amp;, QPair&lt;int, int&gt;&amp;)'
  setField(this-&gt;y, pair);
                        ^
/home/hymir/Entwicklung/cxx/Projekte/TestQTstuff/testb.cpp:22: Fehler:no matching function for call to 'TestB::setField(int*&amp;, QPair&lt;int, int&gt;&amp;)'
  setField(this-&gt;x, pair);
                        ^
</code></pre>
<p>Und hier das passend Minimalbeispiel:<br />
(Datei testa.h)</p>
<pre><code>#include &lt;QPair&gt;

#ifndef TESTA_H
#define TESTA_H

class TestA
{
	public:
		TestA();
		virtual void fromPair(QPair&lt;int, int&gt;&amp; pair);
		int* getX();
		int* getY();
	protected:
		int* x;
		int* y;
		void setField(int* field, QPair&lt;int, int&gt;&amp; pair);
};

#endif // TESTA_H
</code></pre>
<p>(Datei testa.cpp)</p>
<pre><code>#include &quot;testa.h&quot;

TestA::TestA()
	:x(NULL),
		y(NULL)
{
}

void TestA::setField(int *field, QPair&lt;int, int&gt; &amp;pair)
{
	(*field) = pair.first * pair.second;
}

void TestA::fromPair(QPair&lt;int, int&gt; &amp;pair)
{
	setField(this-&gt;x, pair);
	setField(this-&gt;y, pair);
}

int* TestA::getY()
{
	return y;
}

int* TestA::getX()
{
	return x;
}
</code></pre>
<p>(Datei testb.h)</p>
<pre><code>#include &lt;QString&gt;
#include &quot;testa.h&quot;

#ifndef TESTB_H
#define TESTB_H

class TestB : public TestA
{
	public:
		TestB();
		void fromPair(QPair&lt;int, int&gt;&amp; pair);
		QString* getOrig(void);
	protected:
		QString* orig;
		void setField(QString*&amp; field, QPair&lt;int, int&gt; &amp;pair);
};

#endif // TESTB_H
</code></pre>
<p>(Datei testb.cpp)</p>
<pre><code>#include &quot;testb.h&quot;

TestB::TestB()
	:orig(NULL)
{
}

void TestB::setField(QString *&amp;field, QPair&lt;int, int&gt; &amp;pair)
{
	field = new QString();
	field-&gt;append('(');
	field-&gt;append(pair.first);
	field-&gt;append(&quot;, &quot;);
	field-&gt;append(pair.second);
	field-&gt;append(')');
}

void TestB::fromPair(QPair&lt;int, int&gt; &amp;pair)
{
	//TestA::fromPair(pair);
	setField(this-&gt;y, pair);
	setField(this-&gt;x, pair);
	setField(this-&gt;orig, pair);
}
</code></pre>
<p>In der main-funktion erstelle ich ein QPair objekt und ein TestB objekt.<br />
Danach rufe ich testbobjekt.fromPair(myPair) auf, das wars.<br />
Ich habe hier zwar QT Klassen verwendet, sollte aber nicht von Bedeutung sein, wenn man sie gegen irgendetwas anderes austauscht.</p>
<p>Der oben genannte Fehler sieht aus als wäre er ein typischer Fehler in C++.<br />
Bedanke mich herzlich im Voraus für eure Hilfe,<br />
Beste Grüße.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379488</guid><dc:creator><![CDATA[V2-Biker]]></dc:creator><pubDate>Sat, 25 Jan 2014 14:03:40 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 14:24:35 GMT]]></title><description><![CDATA[<pre><code>void setField(QString*&amp; field, QPair&lt;int, int&gt; &amp;pair);
</code></pre>
<pre><code>setField(this-&gt;y, pair);
</code></pre>
<pre><code>int* y;
</code></pre>
<p>Siehst du, was da nicht zusammen passt?</p>
<p>P.S.: Referenzen auf Zeiger auf Zeichenketten? Ist das normal in Qt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379493</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379493</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 25 Jan 2014 14:24:35 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 15:14:59 GMT]]></title><description><![CDATA[<p>Hi, Danke für deine Antwort.</p>
<p>Die entsprechende Methode wird vorn TestA geerbt und ist protected.</p>
<pre><code>void setField(int* field, QPair&lt;int, int&gt;&amp; pair);
</code></pre>
<p>Sie sollte somit verfügbar sein in TestB: public TestA.</p>
<p>Ob Referenzen auf Zeiger auf Strings gängige Praxis in QT sind weiß ich nicht.<br />
Spielt hier aber auch keine Rolle.<br />
Das Testprogramm ist natürlich vollkommener Humbug, schon klar.<br />
Es handelt sich ja nur um ein Minimalbeispiel, das möglichst originalgetreu<br />
die Situation in meinem Projekt nachstellt um genau den &quot;gewünschten&quot; Fehler zu provozieren <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>Was ich nicht verstehe ist, dass er die og. Methode aus der Superklasse nicht zu kennen scheint.<br />
Vorallem bleibt der Fehler, wenn ich diese Methode in der Superklasse public mache.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379509</guid><dc:creator><![CDATA[V2-Biker]]></dc:creator><pubDate>Sat, 25 Jan 2014 15:14:59 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 15:27:19 GMT]]></title><description><![CDATA[<p>Du überlädst die Methode aus der Basisklasse (und damit verdeckst du alle Methoden gleichen Namens der Basisklasse).<br />
Packe noch ein</p>
<pre><code class="language-cpp">using TestA::setField;
</code></pre>
<p>in die Klassendefinition von der abgeleiteten Klasse TestB - s. z.B. <a href="http://msdn.microsoft.com/en-us/library/was37tzw.aspx" rel="nofollow">using Declaration</a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379510</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Sat, 25 Jan 2014 15:27:19 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 15:50:54 GMT]]></title><description><![CDATA[<p>Vielen Dank für den Hinweis,<br />
diese Kleinigkeit hab ich total übersehen:)</p>
<p>Nun läuft alles wie gewünscht.<br />
Soll ich an den Titel &quot;gelöst&quot; anhängen, oder wie markiere ich den entsprechend?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379515</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379515</guid><dc:creator><![CDATA[V2-Biker]]></dc:creator><pubDate>Sat, 25 Jan 2014 15:50:54 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 15:58:33 GMT]]></title><description><![CDATA[<p>V2-Biker schrieb:</p>
<blockquote>
<p>Soll ich an den Titel &quot;gelöst&quot; anhängen, oder wie markiere ich den entsprechend?</p>
</blockquote>
<p>Kannst du so machen, aber kannst du auch einfach so lassen wie es ist. Manchmal kommen später auch noch nützliche allgemeine Tipps oder bessere Lösungen in Threads, deren eigentliche Frage schon gelöst ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2379518</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379518</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Sat, 25 Jan 2014 15:58:33 GMT</pubDate></item><item><title><![CDATA[Reply to g++: no matching function call to &#x27;...&#x27; on Sat, 25 Jan 2014 16:41:02 GMT]]></title><description><![CDATA[<p>Alles klar.<br />
Nochmal vielen Dank, ihr seid klasse! <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>
]]></description><link>https://www.c-plusplus.net/forum/post/2379527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2379527</guid><dc:creator><![CDATA[V2-Biker]]></dc:creator><pubDate>Sat, 25 Jan 2014 16:41:02 GMT</pubDate></item></channel></rss>