<?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[Compiler-Fehlermeldung unklar]]></title><description><![CDATA[<p>Ich habe folgendes geschrieben</p>
<pre><code>class ConnectionKey {
	public:
	uint32_t serverIP;
	uint32_t clientIP;
	ConnectionKey( uint32_t serverIP, uint32_t clientIP );
	bool operator==(ConnectionKey);
};

ConnectionKey::ConnectionKey( uint32_t serverIP_, uint32_t clientIP_ ) {
	serverIP = serverIP_;
	clientIP = clientIP_;
}

bool ConnectionKey::operator==( ConnectionKey&amp; connKey ) {
	if( connKey.serverIP == serverIP &amp;&amp; connKey.clientIP == clientIP )
		return true;
	return false;
}

typedef boost::unordered_map&lt;ConnectionKey, TCPConnection, boost::hash&lt;ConnectionKey&gt; &gt; tcpConnectionsMap;
tcpConnectionsMap tcpConnections;
//weiter im Code...
if( tcpConnections.find( connKey ) == tcpConnections.end() ) { &lt;-- Zeile 172
...
</code></pre>
<p>Wenn ich das nun kompiliere, dann er halte ich folgende Fehlerausgabe:</p>
<blockquote>
<p>ddos_main.cpp:172: instantiated from here<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:200: error: passing ‘const ConnectionKey’ as ‘this’ argument of ‘bool ConnectionKey::operator==(ConnectionKey)’ discards qualifiers</p>
</blockquote>
<p>Was mache ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/272470/compiler-fehlermeldung-unklar</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 21:18:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/272470.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 18 Aug 2010 09:33:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 09:33:25 GMT]]></title><description><![CDATA[<p>Ich habe folgendes geschrieben</p>
<pre><code>class ConnectionKey {
	public:
	uint32_t serverIP;
	uint32_t clientIP;
	ConnectionKey( uint32_t serverIP, uint32_t clientIP );
	bool operator==(ConnectionKey);
};

ConnectionKey::ConnectionKey( uint32_t serverIP_, uint32_t clientIP_ ) {
	serverIP = serverIP_;
	clientIP = clientIP_;
}

bool ConnectionKey::operator==( ConnectionKey&amp; connKey ) {
	if( connKey.serverIP == serverIP &amp;&amp; connKey.clientIP == clientIP )
		return true;
	return false;
}

typedef boost::unordered_map&lt;ConnectionKey, TCPConnection, boost::hash&lt;ConnectionKey&gt; &gt; tcpConnectionsMap;
tcpConnectionsMap tcpConnections;
//weiter im Code...
if( tcpConnections.find( connKey ) == tcpConnections.end() ) { &lt;-- Zeile 172
...
</code></pre>
<p>Wenn ich das nun kompiliere, dann er halte ich folgende Fehlerausgabe:</p>
<blockquote>
<p>ddos_main.cpp:172: instantiated from here<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_function.h:200: error: passing ‘const ConnectionKey’ as ‘this’ argument of ‘bool ConnectionKey::operator==(ConnectionKey)’ discards qualifiers</p>
</blockquote>
<p>Was mache ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941372</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 18 Aug 2010 09:33:25 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 09:40:17 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool operator==(ConnectionKey)const; // &lt;--- const einfügen
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1941378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941378</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 18 Aug 2010 09:40:17 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 09:43:08 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">bool operator==(const ConnectionKey&amp; ) const;
</code></pre>
<p>Besser wäre auch, den Parameter als Referenz zu übergeben, hat aber mit dem Fehler nichts zu tun.</p>
<p>Lars</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941384</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941384</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 18 Aug 2010 09:43:08 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 10:19:25 GMT]]></title><description><![CDATA[<p>Und</p>
<pre><code class="language-cpp">if (x)
  return true;

return false;
</code></pre>
<p>sollte man auch besser gleich durch</p>
<pre><code class="language-cpp">return x;
</code></pre>
<p>ersetzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941415</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 18 Aug 2010 10:19:25 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 10:19:38 GMT]]></title><description><![CDATA[<p>Ich würde den Vergleichsoperator auch als freie Funktion implementieren statt als member.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941416</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941416</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Wed, 18 Aug 2010 10:19:38 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 10:23:02 GMT]]></title><description><![CDATA[<p>Danke für die Hinweise.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941418</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941418</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 18 Aug 2010 10:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler-Fehlermeldung unklar on Wed, 18 Aug 2010 11:39:41 GMT]]></title><description><![CDATA[<p>Verzeih die Werbung - aber der Artikel zur Operatorüberladung im Magazin scheint einigen geholfen zu haben: <a href="http://magazin.c-plusplus.net/artikel/%DCberladung%20von%20Operatoren%20in%20CPlusPlus%20%28Teil%201%29" rel="nofollow">http://magazin.c-plusplus.net/artikel/�berladung von Operatoren in CPlusPlus (Teil 1)</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1941483</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1941483</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Wed, 18 Aug 2010 11:39:41 GMT</pubDate></item></channel></rss>