<?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[Linker-Fehler nach Operator-Overloading]]></title><description><![CDATA[<p>Hallo, ich hab ne kleine Matrix-Klasse geschrieben.</p>
<p>Nun hab ich ne Multiplikation von 2 Matrizen implementiert( * Operator überladen)</p>
<p>Jetzt beschwert sich aber mein Testprogramm, und bringt einen LinkerFehler das ein Symbol bereits mehrfach definiert ist. Muss ich irgendwas in den Buildeinstellungen ändern? Ohne den Operator geht es.</p>
<p>Hier mal der Code</p>
<pre><code class="language-cpp">#pragma once

namespace MRTR
{
	class Matrix
	{
	public:
		enum directions
		{
			X, Y, Z
		};
		Matrix();
		Matrix(float data[]);			
	private:
		void swap(float &amp;a, float &amp;b);
		float m_contents[16];
	};
		Matrix operator*(const Matrix&amp; m1,const Matrix&amp; m2)
		{
			Matrix result;			
			return result;
		}	

}
</code></pre>
<p>Und hier mein Testprogramm, wie gesagt wenn ich in der Matrix.h den Operator weglasse funktioniert es.</p>
<pre><code class="language-cpp">#include &quot;MRTR_Maths\MRTR_Matrix.h&quot;
#include &lt;iostream&gt;
using namespace MRTR;

int main()
{
	Matrix test;
	test.setEntry(12, 4.4444f);		

}
</code></pre>
<p>hier nochmal der Fehler.</p>
<p>MRTR_Maths.lib(MRTR_Matrix.obj) : error LNK2005: &quot;class MRTR::Matrix __cdecl MRTR::operator*(class MRTR::Matrix const &amp;,class MRTR::Matrix const &amp;)&quot; (??DMRTR@@YA?AVMatrix@0@ABV10@0@Z) already defined in test.obj</p>
<p>Debug/test.exe : fatal error LNK1169: one or more multiply defined symbols found</p>
<p>Benutze übrigens Visual Studio NET 2003</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/72497/linker-fehler-nach-operator-overloading</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Apr 2026 01:22:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/72497.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 29 Apr 2004 10:49:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Linker-Fehler nach Operator-Overloading on Thu, 29 Apr 2004 10:49:11 GMT]]></title><description><![CDATA[<p>Hallo, ich hab ne kleine Matrix-Klasse geschrieben.</p>
<p>Nun hab ich ne Multiplikation von 2 Matrizen implementiert( * Operator überladen)</p>
<p>Jetzt beschwert sich aber mein Testprogramm, und bringt einen LinkerFehler das ein Symbol bereits mehrfach definiert ist. Muss ich irgendwas in den Buildeinstellungen ändern? Ohne den Operator geht es.</p>
<p>Hier mal der Code</p>
<pre><code class="language-cpp">#pragma once

namespace MRTR
{
	class Matrix
	{
	public:
		enum directions
		{
			X, Y, Z
		};
		Matrix();
		Matrix(float data[]);			
	private:
		void swap(float &amp;a, float &amp;b);
		float m_contents[16];
	};
		Matrix operator*(const Matrix&amp; m1,const Matrix&amp; m2)
		{
			Matrix result;			
			return result;
		}	

}
</code></pre>
<p>Und hier mein Testprogramm, wie gesagt wenn ich in der Matrix.h den Operator weglasse funktioniert es.</p>
<pre><code class="language-cpp">#include &quot;MRTR_Maths\MRTR_Matrix.h&quot;
#include &lt;iostream&gt;
using namespace MRTR;

int main()
{
	Matrix test;
	test.setEntry(12, 4.4444f);		

}
</code></pre>
<p>hier nochmal der Fehler.</p>
<p>MRTR_Maths.lib(MRTR_Matrix.obj) : error LNK2005: &quot;class MRTR::Matrix __cdecl MRTR::operator*(class MRTR::Matrix const &amp;,class MRTR::Matrix const &amp;)&quot; (??DMRTR@@YA?AVMatrix@0@ABV10@0@Z) already defined in test.obj</p>
<p>Debug/test.exe : fatal error LNK1169: one or more multiply defined symbols found</p>
<p>Benutze übrigens Visual Studio NET 2003</p>
]]></description><link>https://www.c-plusplus.net/forum/post/510986</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/510986</guid><dc:creator><![CDATA[mrtrashtalk]]></dc:creator><pubDate>Thu, 29 Apr 2004 10:49:11 GMT</pubDate></item><item><title><![CDATA[Reply to Linker-Fehler nach Operator-Overloading on Thu, 29 Apr 2004 12:08:36 GMT]]></title><description><![CDATA[<p>noch was, wenn ich den operator als friend in die klasse selber reinpacke, funktioniert es. Ich möchte aber gerne wissen, wieso die andere methode nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/511060</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/511060</guid><dc:creator><![CDATA[mrtrashtalk]]></dc:creator><pubDate>Thu, 29 Apr 2004 12:08:36 GMT</pubDate></item><item><title><![CDATA[Reply to Linker-Fehler nach Operator-Overloading on Thu, 29 Apr 2004 12:21:04 GMT]]></title><description><![CDATA[<p>möglichkeit 1: prototyp in den header-&gt;implementierung in die cpp<br />
möglichkeit 2: project-&gt;settings-&gt;link-&gt;customize-&gt;force file output</p>
]]></description><link>https://www.c-plusplus.net/forum/post/511072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/511072</guid><dc:creator><![CDATA[Sovok]]></dc:creator><pubDate>Thu, 29 Apr 2004 12:21:04 GMT</pubDate></item><item><title><![CDATA[Reply to Linker-Fehler nach Operator-Overloading on Thu, 29 Apr 2004 12:32:17 GMT]]></title><description><![CDATA[<p>und wenn du ganz sicher bist, das alles richtig sein müsste... lösche mal den debug ordner. (entweder per hand oder mit bereinigen als unterpunkt)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/511091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/511091</guid><dc:creator><![CDATA[elise]]></dc:creator><pubDate>Thu, 29 Apr 2004 12:32:17 GMT</pubDate></item><item><title><![CDATA[Reply to Linker-Fehler nach Operator-Overloading on Thu, 29 Apr 2004 13:25:30 GMT]]></title><description><![CDATA[<p>elise schrieb:</p>
<blockquote>
<p>und wenn du ganz sicher bist, das alles richtig sein müsste... lösche mal den debug ordner. (entweder per hand oder mit bereinigen als unterpunkt)</p>
</blockquote>
<p>hab ich schon beides probiert, funktioniert leider nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/511131</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/511131</guid><dc:creator><![CDATA[mrtrashtalk]]></dc:creator><pubDate>Thu, 29 Apr 2004 13:25:30 GMT</pubDate></item></channel></rss>