<?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[Linking Error mit operator Überladung]]></title><description><![CDATA[<p>hi,</p>
<p>habe ein Problem mit operator Überladung das mich zu Verzweiflung treibt.<br />
Lässt sich dur den Code am besten erklären xD<br />
Fehler Meldung:</p>
<pre><code>Fehler	1	error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: class Ip &amp; __thiscall Ip::operator++(void)&quot; (??EIp@@QAEAAV0@XZ)&quot;.	main.obj	PortScanCPP
</code></pre>
<p>Header:</p>
<pre><code class="language-cpp">#pragma once

#include &quot;main.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;

class Ip
{
protected:
	UINT32 _ipDez;
	UINT32 ToDez(const std::string &amp;ip);
public:
	Ip(const std::string &amp;ipString);
	Ip(const char ipCString[]);
	Ip(UINT32 ip);
	Ip(Ip &amp;ip);
	std::string &amp; ToString(std::string &amp;s);
	inline bool IsValid();

	/* Operatoren */
	friend std::istream&amp; operator&gt;&gt;(std::istream&amp; is, Ip&amp; val);
	friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Ip&amp; val);

	inline Ip&amp; operator++();
	inline Ip&amp; operator--();
	inline Ip operator++(int);
	inline Ip operator--(int);

	inline Ip&amp; operator+=(const int n);
	inline Ip&amp; operator-=(const int n);
	inline Ip operator+(const int n);
	inline Ip operator-(const int n);

	Ip&amp; operator=(const std::string s);
	Ip&amp; operator=(const char ipCString[]);

	inline bool operator==(const Ip&amp; ip);
	inline bool operator!=(const Ip&amp; ip);
	inline bool operator&lt;(const Ip&amp; ip);
	inline bool operator&gt;(const Ip&amp; ip);
};
</code></pre>
<p>Ausschnitt aus der *.cpp</p>
<pre><code class="language-cpp">Ip&amp; Ip::operator++()
{
	this-&gt;_ipDez++;
	return *this;
}
Ip&amp; Ip::operator--()
{
	this-&gt;_ipDez--;
	return *this;
}
Ip Ip::operator++(int)
{
	Ip old = *this;
	this-&gt;_ipDez++;
	return old;
}
Ip Ip::operator--(int)
{
	Ip old = *this;
	this-&gt;_ipDez--;
	return old;
}
</code></pre>
<p>und zum Testen in der main</p>
<pre><code class="language-cpp">Ip i(&quot;127.0.0.1&quot;);
cout &lt;&lt; &quot;Ip:&quot; &lt;&lt; i &lt;&lt; endl;
cout &lt;&lt; &quot;++Ip:&quot; &lt;&lt; ++i &lt;&lt; endl;
i = &quot;192.168.220.107&quot;;
cout &lt;&lt; &quot;Ip:&quot; &lt;&lt; i &lt;&lt; endl;
</code></pre>
<p>Wenn die 3. Zeile auskommentiert ist funktionierts (was ja klar ist xD), aber mit kommt der Linking Error.<br />
Am Anfang gings mit dem COde auch, als ich ahber dann noch mehr Operatoren eingebaut hab gings nicht mehr (&lt;,&gt;,==,!=,+,-,+=,-= ohne die gings mal, als ich den code wieder auskommentiert hab gings erst nich, nach 100mal rumprobieren dann doch wieder ..)</p>
<p>Weiß jemand wo mein Fehler liegt?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/260585/linking-error-mit-operator-überladung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 00:32:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/260585.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Feb 2010 13:43:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 13:43:14 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>habe ein Problem mit operator Überladung das mich zu Verzweiflung treibt.<br />
Lässt sich dur den Code am besten erklären xD<br />
Fehler Meldung:</p>
<pre><code>Fehler	1	error LNK2001: Nicht aufgelöstes externes Symbol &quot;&quot;public: class Ip &amp; __thiscall Ip::operator++(void)&quot; (??EIp@@QAEAAV0@XZ)&quot;.	main.obj	PortScanCPP
</code></pre>
<p>Header:</p>
<pre><code class="language-cpp">#pragma once

#include &quot;main.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;

class Ip
{
protected:
	UINT32 _ipDez;
	UINT32 ToDez(const std::string &amp;ip);
public:
	Ip(const std::string &amp;ipString);
	Ip(const char ipCString[]);
	Ip(UINT32 ip);
	Ip(Ip &amp;ip);
	std::string &amp; ToString(std::string &amp;s);
	inline bool IsValid();

	/* Operatoren */
	friend std::istream&amp; operator&gt;&gt;(std::istream&amp; is, Ip&amp; val);
	friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, Ip&amp; val);

	inline Ip&amp; operator++();
	inline Ip&amp; operator--();
	inline Ip operator++(int);
	inline Ip operator--(int);

	inline Ip&amp; operator+=(const int n);
	inline Ip&amp; operator-=(const int n);
	inline Ip operator+(const int n);
	inline Ip operator-(const int n);

	Ip&amp; operator=(const std::string s);
	Ip&amp; operator=(const char ipCString[]);

	inline bool operator==(const Ip&amp; ip);
	inline bool operator!=(const Ip&amp; ip);
	inline bool operator&lt;(const Ip&amp; ip);
	inline bool operator&gt;(const Ip&amp; ip);
};
</code></pre>
<p>Ausschnitt aus der *.cpp</p>
<pre><code class="language-cpp">Ip&amp; Ip::operator++()
{
	this-&gt;_ipDez++;
	return *this;
}
Ip&amp; Ip::operator--()
{
	this-&gt;_ipDez--;
	return *this;
}
Ip Ip::operator++(int)
{
	Ip old = *this;
	this-&gt;_ipDez++;
	return old;
}
Ip Ip::operator--(int)
{
	Ip old = *this;
	this-&gt;_ipDez--;
	return old;
}
</code></pre>
<p>und zum Testen in der main</p>
<pre><code class="language-cpp">Ip i(&quot;127.0.0.1&quot;);
cout &lt;&lt; &quot;Ip:&quot; &lt;&lt; i &lt;&lt; endl;
cout &lt;&lt; &quot;++Ip:&quot; &lt;&lt; ++i &lt;&lt; endl;
i = &quot;192.168.220.107&quot;;
cout &lt;&lt; &quot;Ip:&quot; &lt;&lt; i &lt;&lt; endl;
</code></pre>
<p>Wenn die 3. Zeile auskommentiert ist funktionierts (was ja klar ist xD), aber mit kommt der Linking Error.<br />
Am Anfang gings mit dem COde auch, als ich ahber dann noch mehr Operatoren eingebaut hab gings nicht mehr (&lt;,&gt;,==,!=,+,-,+=,-= ohne die gings mal, als ich den code wieder auskommentiert hab gings erst nich, nach 100mal rumprobieren dann doch wieder ..)</p>
<p>Weiß jemand wo mein Fehler liegt?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851866</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851866</guid><dc:creator><![CDATA[leb0rtran]]></dc:creator><pubDate>Sun, 07 Feb 2010 13:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 13:51:49 GMT]]></title><description><![CDATA[<p>Dein Fehler?<br />
Du hast den Artikel noch nicht gelesen:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-232010.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-232010.html</a><br />
Da steht dann auch genau drinnen, was du falsch machst...</p>
<p>// edit:<br />
Kleiner Tipp:<br />
operator++() -&gt; ++val<br />
operator++(int) -&gt; val++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851870</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Sun, 07 Feb 2010 13:51:49 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:07:14 GMT]]></title><description><![CDATA[<p>ich versteh nich was du mir sagen willst,<br />
ich hab den artikel schon gelesen, und mir ist klar dass operator++() Praeinkrement und operator++(int) Postinkrement ist.</p>
<p>Das Problem hier ist meines Erachtens ein anderes, da ja der Passende Operator nicht gefunden wird, da er aber in der cpp Datei definiert ist, weiß ich nicht warum.</p>
<p>Btw, tritt nicht nur mit ++ und -- auf, sondern auch mit allen anderen, bis auf den zuweißungsoperator, also auch i + 5; geht nicht.</p>
<p>Der einzigste Unterschied zwischen den funktionierenden und nciht-funktionierend Operatoren ist ja das inline, aber nach entfernen des Schlüsselworts hats immernoch nciht funktioniert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851883</guid><dc:creator><![CDATA[leb0rtran]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:07:14 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:14:45 GMT]]></title><description><![CDATA[<p>Und du bist dir ganz sicher, dass du die &quot;Ip_Impl.cpp&quot; mitkompilierst und auch zu deiner Executable linkst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851885</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:14:45 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:27:12 GMT]]></title><description><![CDATA[<p>da ja die Zuweißungsoperatoren und die ganz normalen Methoden und Konstruktoren funktionieren, und die komplette Implementiereung in einer Datei steht geh ich mal schwer davon aus</p>
<p>edit, hab grad mal die Implementation des Praefix Operators und die header Datei geschoben, dann funktionierts ...</p>
<p>edit2:<br />
wo sieht man in vs2008 eig welche dateien alle mitkompliliert werden?<br />
dachte bisher eig immer alle die im Projektexplorer zu sehen sind</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851889</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851889</guid><dc:creator><![CDATA[leb0rtran]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:27:12 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:26:39 GMT]]></title><description><![CDATA[<p>Fällt mir jetzt erst auf:<br />
Nimm die inline bei der Klassendefinition weg! Dalli!<br />
Die gehören bei der Definition der Methoden hin!<br />
Dann verschwinden magischerweise die undefined references!<br />
Hast du denn keine Warnings bekommen?</p>
<pre><code>test.h:4: Warnung: inline-Funktion »void Test::bla() const« verwendet, aber nirgendwo definiert
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1851893</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851893</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:26:39 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:33:34 GMT]]></title><description><![CDATA[<p>ok, wenn ich alle inlines komplett raus nehm gehts,<br />
wenn ich sie aber in die cpp datei reinschreib gehts auch nicht, (wie vorher als sie in der .h waren)</p>
<p>Warning kam vorher keine, und jetzt auch nicht ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851895</guid><dc:creator><![CDATA[leb0rtran]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:33:34 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:38:11 GMT]]></title><description><![CDATA[<p>Wenn du was inline haben willst, muss das in den Header!</p>
<pre><code class="language-cpp">struct Test
{
    void bla1() {   // implizit inline
        doWhat();
    }
    void bla2();
    void bla3();
};

inline void
Test::bla2() {    // explizit inline
    doWhat();
}

void
Test::bla3()    // lassen wir den Compiler optimieren
{
    doWhat();
}
</code></pre>
<p>Alles im Header.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851902</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851902</guid><dc:creator><![CDATA[l&#x27;abra d&#x27;or]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:38:11 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 14:51:59 GMT]]></title><description><![CDATA[<p>ahh ok,<br />
soll heißen, bei allem was inline is kann ich nichmehr zwischen Schnittstelle und Implementation trennen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851911</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851911</guid><dc:creator><![CDATA[leb0rtran]]></dc:creator><pubDate>Sun, 07 Feb 2010 14:51:59 GMT</pubDate></item><item><title><![CDATA[Reply to Linking Error mit operator Überladung on Sun, 07 Feb 2010 15:18:32 GMT]]></title><description><![CDATA[<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-105893-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-105893-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1851935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1851935</guid><dc:creator><![CDATA[Zeus]]></dc:creator><pubDate>Sun, 07 Feb 2010 15:18:32 GMT</pubDate></item></channel></rss>