<?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[error C2678 bei Operatorenüberladung in MSVC Express 2005]]></title><description><![CDATA[<p>Ich bekomme einen error C2678 bei einer Operatorenüberladung. Über Internet-postings habe ich gelesen, es sein ein compiler-spezifischer error, daher poste ich hier.<br />
Der code:</p>
<pre><code>static struct ErrorEntry 
{
    int nID;
    const char* pcMessage;

    ErrorEntry(int id, const char* pc = 0) : 
    nID(id), 
    pcMessage(pc) 
    { 
    }

    bool operator&lt;(const ErrorEntry&amp; rhs) 
    {
        return nID &lt; rhs.nID;
    }
};
</code></pre>
<p>Die Fehlermeldung lautet:</p>
<pre><code>c:\programme\microsoft visual studio 8\vc\include\xutility(267) : error C2678: Binärer Operator '&lt;': Es konnte kein Operator gefunden werden, der einen linksseitigen Operanden vom Typ 'const ErrorEntry' akzeptiert (oder keine geeignete Konvertierung möglich)
        (...)\ws-util.cpp(45): kann 'bool ErrorEntry::operator &lt;(const ErrorEntry &amp;)' sein
        bei Anpassung der Argumentliste '(const ErrorEntry, ErrorEntry)'
        c:\programme\microsoft visual studio 8\vc\include\algorithm(1992): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;bool std::_Debug_lt&lt;ErrorEntry,_Ty&gt;(_Ty1 &amp;,const _Ty2 &amp;,const wchar_t *,unsigned int)&quot;.
        with
        [
            _Ty=ErrorEntry,
            _Ty1=ErrorEntry,
            _Ty2=ErrorEntry
        ]
        c:\programme\microsoft visual studio 8\vc\include\algorithm(2004): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;_FwdIt std::_Lower_bound&lt;ErrorEntry*,_Ty,std::iterator_traits&lt;_Iter&gt;::difference_type&gt;(_FwdIt,_FwdIt,const _Ty &amp;,_Diff *)&quot;.
        with
        [
            _FwdIt=ErrorEntry *,
            _Ty=ErrorEntry,
            _Iter=ErrorEntry *,
            _Diff=std::iterator_traits&lt;ErrorEntry *&gt;::difference_type
        ]
       (...)\ws-util.cpp(128): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;_FwdIt std::lower_bound&lt;ErrorEntry*,ErrorEntry&gt;(_FwdIt,_FwdIt,const _Ty &amp;)&quot;.
        with
        [
            _FwdIt=ErrorEntry *,
            _Ty=ErrorEntry
        ]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/153039/error-c2678-bei-operatorenüberladung-in-msvc-express-2005</link><generator>RSS for Node</generator><lastBuildDate>Mon, 07 Sep 2026 04:34:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/153039.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Jul 2006 09:52:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to error C2678 bei Operatorenüberladung in MSVC Express 2005 on Wed, 12 Jul 2006 09:52:59 GMT]]></title><description><![CDATA[<p>Ich bekomme einen error C2678 bei einer Operatorenüberladung. Über Internet-postings habe ich gelesen, es sein ein compiler-spezifischer error, daher poste ich hier.<br />
Der code:</p>
<pre><code>static struct ErrorEntry 
{
    int nID;
    const char* pcMessage;

    ErrorEntry(int id, const char* pc = 0) : 
    nID(id), 
    pcMessage(pc) 
    { 
    }

    bool operator&lt;(const ErrorEntry&amp; rhs) 
    {
        return nID &lt; rhs.nID;
    }
};
</code></pre>
<p>Die Fehlermeldung lautet:</p>
<pre><code>c:\programme\microsoft visual studio 8\vc\include\xutility(267) : error C2678: Binärer Operator '&lt;': Es konnte kein Operator gefunden werden, der einen linksseitigen Operanden vom Typ 'const ErrorEntry' akzeptiert (oder keine geeignete Konvertierung möglich)
        (...)\ws-util.cpp(45): kann 'bool ErrorEntry::operator &lt;(const ErrorEntry &amp;)' sein
        bei Anpassung der Argumentliste '(const ErrorEntry, ErrorEntry)'
        c:\programme\microsoft visual studio 8\vc\include\algorithm(1992): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;bool std::_Debug_lt&lt;ErrorEntry,_Ty&gt;(_Ty1 &amp;,const _Ty2 &amp;,const wchar_t *,unsigned int)&quot;.
        with
        [
            _Ty=ErrorEntry,
            _Ty1=ErrorEntry,
            _Ty2=ErrorEntry
        ]
        c:\programme\microsoft visual studio 8\vc\include\algorithm(2004): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;_FwdIt std::_Lower_bound&lt;ErrorEntry*,_Ty,std::iterator_traits&lt;_Iter&gt;::difference_type&gt;(_FwdIt,_FwdIt,const _Ty &amp;,_Diff *)&quot;.
        with
        [
            _FwdIt=ErrorEntry *,
            _Ty=ErrorEntry,
            _Iter=ErrorEntry *,
            _Diff=std::iterator_traits&lt;ErrorEntry *&gt;::difference_type
        ]
       (...)\ws-util.cpp(128): Siehe Verweis auf die Instanziierung der gerade kompilierten Funktions-template &quot;_FwdIt std::lower_bound&lt;ErrorEntry*,ErrorEntry&gt;(_FwdIt,_FwdIt,const _Ty &amp;)&quot;.
        with
        [
            _FwdIt=ErrorEntry *,
            _Ty=ErrorEntry
        ]
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1096279</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096279</guid><dc:creator><![CDATA[Serethos]]></dc:creator><pubDate>Wed, 12 Jul 2006 09:52:59 GMT</pubDate></item><item><title><![CDATA[Reply to error C2678 bei Operatorenüberladung in MSVC Express 2005 on Wed, 12 Jul 2006 10:38:18 GMT]]></title><description><![CDATA[<p>Erstens ist das kein Compiler-spezifisches Problem, sondern tritt vermutlich überall auf (mit unterschiedlichen Fehlercodes).</p>
<p>Zweitens zur Lösung:<br />
Dein operator&lt; kann nur angewendet werden, wenn auf der linken Seite ein nicht-konstantes Objekt steht. Allerdings hast du an der Stelle, wo er aufgerufen werden soll, nur ein &quot;const ErrorEntry&quot; zur Verfügung. Da der Operator nicht vorhat, etwas an this zu ändern, kannst du ihn aber problemlos als const deklarieren, was dein Problem lösen sollte:</p>
<pre><code class="language-cpp">static struct ErrorEntry 
{
    int nID;
    const char* pcMessage;

    ErrorEntry(int id, const char* pc = 0) : 
    nID(id), 
    pcMessage(pc) 
    { 
    }

    bool operator&lt;(const ErrorEntry&amp; rhs) /*Das ist wichtig:*/ const
    {
        return nID &lt; rhs.nID;
    }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1096315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096315</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 12 Jul 2006 10:38:18 GMT</pubDate></item><item><title><![CDATA[Reply to error C2678 bei Operatorenüberladung in MSVC Express 2005 on Wed, 12 Jul 2006 10:38:28 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=18038" rel="nofollow">CStoll</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=1" rel="nofollow">MFC (Visual C++)</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1096316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096316</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 12 Jul 2006 10:38:28 GMT</pubDate></item><item><title><![CDATA[Reply to error C2678 bei Operatorenüberladung in MSVC Express 2005 on Wed, 12 Jul 2006 12:45:33 GMT]]></title><description><![CDATA[<p>Vielen Dank für Deine Hilfe, Problem ist gelöst!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1096415</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1096415</guid><dc:creator><![CDATA[Serethos]]></dc:creator><pubDate>Wed, 12 Jul 2006 12:45:33 GMT</pubDate></item></channel></rss>