<?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[Probleme beim überladen von operator&amp;lt;&amp;lt;]]></title><description><![CDATA[<p>Hallo, ich bin zugegeben ziemlicher Anfänger in c++ und bin zur Zeit ein bissl dabei auszuprobieren, habe jetzt aber (oder deswegen) ein Problem beim überladen des operator&lt;&lt;. Die Klassendeklaration</p>
<pre><code>class Held
{
private:
	...
public:
	...
	friend std::ostream operator&lt;&lt;(std::ostream out, Held held);
};
</code></pre>
<p>und die Implementierung</p>
<pre><code>ostream operator&lt;&lt;(ostream &amp; os, const Held &amp; held)
{
	return os;
}
</code></pre>
<p>gibt mir das Visual Studio 2012 die Fehlermeldung</p>
<p>1 IntelliSense: Auf &quot;&quot;std::basic_ostream&lt;_Elem, _Traits&gt;::basic_ostream(const std::basic_ostream&lt;_Elem, _Traits&gt;::_Myt &amp;_Right) [mit _Elem=char, _Traits=std::char_traits&lt;char&gt;]&quot; (deklariert in Zeile 82 von &quot;C:\Program Files\Microsoft Visual Studio 11.0\VC\include\ostream&quot;)&quot; kann nicht zugegriffen werden. c:\Users\Tobias\Documents\Visual Studio 2010\Projects\DSA-Schnipsel\DSA-Schnipsel\Ein paar Klassendefinitionen.cpp 68 9 DSA-Schnipsel</p>
<p>Das Visual Studio hatte noch geschrieben ich würde auf private memberfunktionen zugreifen, aber ich kapiere einfach nicht was ich falsch mache. Ich greife doch nirgends auf irgendwelche privaten member zu oder so natürlich ist #include&lt;iostream&gt; und auch using std::ostream; jeweils vorhanden.</p>
<p>irgendwelche Ideen?<br />
Danke schonmal und viele Grüße<br />
Tobias</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/320973/probleme-beim-überladen-von-operator-lt-lt</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 13:14:49 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320973.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 19 Oct 2013 10:54:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 10:54:44 GMT]]></title><description><![CDATA[<p>Hallo, ich bin zugegeben ziemlicher Anfänger in c++ und bin zur Zeit ein bissl dabei auszuprobieren, habe jetzt aber (oder deswegen) ein Problem beim überladen des operator&lt;&lt;. Die Klassendeklaration</p>
<pre><code>class Held
{
private:
	...
public:
	...
	friend std::ostream operator&lt;&lt;(std::ostream out, Held held);
};
</code></pre>
<p>und die Implementierung</p>
<pre><code>ostream operator&lt;&lt;(ostream &amp; os, const Held &amp; held)
{
	return os;
}
</code></pre>
<p>gibt mir das Visual Studio 2012 die Fehlermeldung</p>
<p>1 IntelliSense: Auf &quot;&quot;std::basic_ostream&lt;_Elem, _Traits&gt;::basic_ostream(const std::basic_ostream&lt;_Elem, _Traits&gt;::_Myt &amp;_Right) [mit _Elem=char, _Traits=std::char_traits&lt;char&gt;]&quot; (deklariert in Zeile 82 von &quot;C:\Program Files\Microsoft Visual Studio 11.0\VC\include\ostream&quot;)&quot; kann nicht zugegriffen werden. c:\Users\Tobias\Documents\Visual Studio 2010\Projects\DSA-Schnipsel\DSA-Schnipsel\Ein paar Klassendefinitionen.cpp 68 9 DSA-Schnipsel</p>
<p>Das Visual Studio hatte noch geschrieben ich würde auf private memberfunktionen zugreifen, aber ich kapiere einfach nicht was ich falsch mache. Ich greife doch nirgends auf irgendwelche privaten member zu oder so natürlich ist #include&lt;iostream&gt; und auch using std::ostream; jeweils vorhanden.</p>
<p>irgendwelche Ideen?<br />
Danke schonmal und viele Grüße<br />
Tobias</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361348</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361348</guid><dc:creator><![CDATA[Takirion]]></dc:creator><pubDate>Sat, 19 Oct 2013 10:54:44 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 11:00:22 GMT]]></title><description><![CDATA[<p>Takirion schrieb:</p>
<blockquote>
<pre><code>ostream operator&lt;&lt;(ostream &amp; os, const Held &amp; held)
{
	return os;
}
</code></pre>
</blockquote>
<p>Guck Dir den Rückgabewert nochmal genau an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361349</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Sat, 19 Oct 2013 11:00:22 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 11:04:00 GMT]]></title><description><![CDATA[<p>Ähm:<br />
s/Rückgabewert/Rückgabetyp/</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361350</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Sat, 19 Oct 2013 11:04:00 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 11:07:38 GMT]]></title><description><![CDATA[<p>In der Deklaration fehlen auch die Referenz-&amp;:</p>
<pre><code class="language-cpp">friend std::ostream operator&lt;&lt;(std::ostream out, Held held);
                   //   ^-- hier                ^-- und hier
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2361351</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361351</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Sat, 19 Oct 2013 11:07:38 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 12:39:02 GMT]]></title><description><![CDATA[<p>Das private bezieht sich auf ostream, nicht auf class Held.<br />
Wenn du den Rückgabetyp oder Parameter std::ostream benutzt, dann muss ein std::ostream kopiert werden. Der Copy-Constructor ostream(const ostream &amp;) ist jedoch private und du kannst ihn deshalb nicht benutzen, weshalb dein Compiler meckert. Mit anderen Worten: Man kann ostreams nicht kopieren.<br />
Die Lösung ist wie schon gesagt ostream &amp; zu benutzen, denn das sind Referenzen auf ein ostream, die man im Gegensatz zu einem ostream kopieren kann.</p>
<p>Die Hinweise &quot;sieh dir den Rückgabetyp an&quot; finde ich etwas irreführend, denn es ist nicht falsch einen ostream übergeben zu wollen. Dass es nicht geht liegt an der Limitierung von ostream, nicht am Parameter. Man kann aber durch geschicktere Wahl des Parameters die Limitierung / unnötige Kopien umgehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361358</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Sat, 19 Oct 2013 12:39:02 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 13:25:06 GMT]]></title><description><![CDATA[<p>Hm, ok nachdem ich jetzt in die Ecke gegangen bin und mich geschämt habe... funktioniert das Kompilieren einwandfrei...<br />
allerdings bekomme ich wenn ich in main() die Zeile cout&lt;&lt;spieler1 (ist vom Typ Held) einfüge die Linker-Meldung 1&gt;Haupt.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol &quot;&quot;class std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp; __cdecl operator&lt;&lt;(class std::basic_ostream&lt;char,struct std::char_traits&lt;char&gt; &gt; &amp;,class Held &amp;)&quot; (??6@YAAAV?<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>b</mi><mi>a</mi><mi>s</mi><mi>i</mi><mi>c</mi><mi mathvariant="normal">_</mi><mi>o</mi><mi>s</mi><mi>t</mi><mi>r</mi><mi>e</mi><mi>a</mi><mi>m</mi><mi mathvariant="normal">@</mi><mi>D</mi><mi>U</mi><mo>?</mo></mrow><annotation encoding="application/x-tex">basic\_ostream@DU?</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.69444em;"></span><span class="strut bottom" style="height:1.00444em;vertical-align:-0.31em;"></span><span class="base textstyle uncramped"><span class="mord mathit">b</span><span class="mord mathit">a</span><span class="mord mathit">s</span><span class="mord mathit">i</span><span class="mord mathit">c</span><span class="mord mathrm" style="margin-right:0.02778em;">_</span><span class="mord mathit">o</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mord mathit" style="margin-right:0.02778em;">r</span><span class="mord mathit">e</span><span class="mord mathit">a</span><span class="mord mathit">m</span><span class="mord mathrm">@</span><span class="mord mathit" style="margin-right:0.02778em;">D</span><span class="mord mathit" style="margin-right:0.10903em;">U</span><span class="mclose">?</span></span></span></span>char_traits@D@std@@@std@@AAV01@AAVHeld@@@Z)&quot; in Funktion &quot;_main&quot;.<br />
was laut google irgendwie damit zusammen zu hängen scheint dass ich Bibliotheken falsch eingebunden hätte? Wie würde ich denn im VS2010 oder auch VS2012 Bibliotheken einbinden bzw. ich war der Meinung dass einer der Vorteile von Visual Studio ist, dass es Bibliotheken automatisch einbindet... oder kann das noch an was anderem liegen.</p>
<p>nochmals danke und liebe Grüße<br />
Takirion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361373</guid><dc:creator><![CDATA[Takirion]]></dc:creator><pubDate>Sat, 19 Oct 2013 13:25:06 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 13:28:13 GMT]]></title><description><![CDATA[<p>Der Rückgabewert der Definition passt nicht zu dem der Deklaration.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361374</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361374</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 19 Oct 2013 13:28:13 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 13:31:48 GMT]]></title><description><![CDATA[<p>Das hat mit Bibliotheken nichts zu tun, er findet einfach die Funktion<br />
ostream &amp; operator &lt;&lt; (ostream &amp;os, Held &amp;h) nicht.<br />
Wahrscheinlich hast du eine Deklaration mit const Held &amp; und eine Implementation mit Held &amp;. Das sind 2 verschiedene Funktionen. Er versucht die Held &amp;-Funktion aufzurufen und findet keine Implementation.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361376</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361376</guid><dc:creator><![CDATA[nwp3]]></dc:creator><pubDate>Sat, 19 Oct 2013 13:31:48 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme beim überladen von operator&amp;lt;&amp;lt; on Sat, 19 Oct 2013 13:44:33 GMT]]></title><description><![CDATA[<p>Ok, irgendwer hat mal behauptet programmieren wäre eine Konzentrationssache... ich weiß so langsam was er meinte. Vielen Dank euch allen. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2361378</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2361378</guid><dc:creator><![CDATA[Takirion]]></dc:creator><pubDate>Sat, 19 Oct 2013 13:44:33 GMT</pubDate></item></channel></rss>