<?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[Überladen von operator&amp;lt;&amp;lt;]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe zurzeit keine plan wie ich an eine bestimmte Sache rangehen soll.<br />
Ich habe mit das Tutorial hier auf <a href="http://c-plusplus.net" rel="nofollow">c-plusplus.net</a> zu den &lt;&lt;operator angesehen, nur ist das sehr kurz.</p>
<p>Naja also was ich eig. erreichen wollte ist</p>
<pre><code>MyClass &lt;&lt; &quot;teststring&quot; &lt;&lt; myclass::color1;
</code></pre>
<p>teststringist ein String und hinter myclass::color1 ist ein enum.</p>
<p>Ich weiß leider garnicht wie ich daran gehen soll</p>
<pre><code class="language-cpp">std::ostream&amp; operator &lt;&lt;(std::ostream &amp;ostr,Myclass const&amp; myclassinst);
</code></pre>
<p>Und dann ?Kein plan.</p>
<p>Vielen Dank schonmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/300037/überladen-von-operator-lt-lt</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 23:45:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/300037.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Feb 2012 19:05:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:05:28 GMT]]></title><description><![CDATA[<p>Hallo.</p>
<p>Ich habe zurzeit keine plan wie ich an eine bestimmte Sache rangehen soll.<br />
Ich habe mit das Tutorial hier auf <a href="http://c-plusplus.net" rel="nofollow">c-plusplus.net</a> zu den &lt;&lt;operator angesehen, nur ist das sehr kurz.</p>
<p>Naja also was ich eig. erreichen wollte ist</p>
<pre><code>MyClass &lt;&lt; &quot;teststring&quot; &lt;&lt; myclass::color1;
</code></pre>
<p>teststringist ein String und hinter myclass::color1 ist ein enum.</p>
<p>Ich weiß leider garnicht wie ich daran gehen soll</p>
<pre><code class="language-cpp">std::ostream&amp; operator &lt;&lt;(std::ostream &amp;ostr,Myclass const&amp; myclassinst);
</code></pre>
<p>Und dann ?Kein plan.</p>
<p>Vielen Dank schonmal.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184874</guid><dc:creator><![CDATA[7xCore]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:05:28 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:14:48 GMT]]></title><description><![CDATA[<p>Also. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f611.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--expressionless_face"
      title="-_-"
      alt="😑"
    /></p>
<pre><code class="language-cpp">std::ostream&amp; operator &lt;&lt;(std::ostream &amp;ostr,Myclass const&amp; myclassinst)
{
    return ostr &lt;&lt; myclassinst.get_Variable1() &lt;&lt; '\n';
}
</code></pre>
<p>Nicht so schwer, oder.<br />
<a href="http://codepad.org/fb7O2FS9" rel="nofollow">Codepad.</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184875</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:14:48 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:07:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">MyClass&amp; operator &lt;&lt; (MyClass&amp; myclass, SomeOtherClass const&amp; other)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2184877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184877</guid><dc:creator><![CDATA[314159265358979__]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:07:55 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:18:16 GMT]]></title><description><![CDATA[<p>War das echt PI?</p>
<p>Edit: Ach Nein! Du Armer wurdest doch nicht gebannt?</p>
<p><a href="http://www.willemer.de/informatik/cpp/cppovrld.htm" rel="nofollow">@TE: Echt blöd. Als ob Google nicht helfen würde!</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184881</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184881</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:18:16 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:20:38 GMT]]></title><description><![CDATA[<p>Ich bin nicht arm, ich wurde zurecht gebannt :'D</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184885</guid><dc:creator><![CDATA[314159265358979__]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:20:38 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:24:43 GMT]]></title><description><![CDATA[<p>Ok das von PI war so am nähersten dran.Ich hab jetzt selbst nochmal geschaut.<br />
So möchte ich, das mein endcode &quot;ist&quot;</p>
<pre><code>enum COLOR_CODE
{
BLACK,WHITE,YELLOW
};

COLOR_CODE operator&lt;&lt;(COLOR_CODE&amp; CC,std::string x)
{
 //hier sollte es dann so sein dass es den string einfach nimmt und meine //schon fertige color funktion anwendet
 myclass.setfontcolor(byte Color);
//hier dann wird das enum CC verarbeitet
std::cout &lt;&lt; x;
}

COLOR_CODE test;
test &lt;&lt; COLOR_CODE::YELLOW &lt;&lt; &quot;TEST&quot;;
</code></pre>
<p>Ok hab deinen link erst jetzt gesehen.Werd's mir jetzt durchlesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184886</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184886</guid><dc:creator><![CDATA[7xCore]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:24:43 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Thu, 23 Feb 2012 19:30:44 GMT]]></title><description><![CDATA[<p>Ahh ok danke Hacker hab mir deinen Codepad code angesehen und habs jetzt verstanden.Danke man.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2184896</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2184896</guid><dc:creator><![CDATA[7xCore]]></dc:creator><pubDate>Thu, 23 Feb 2012 19:30:44 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Fri, 24 Feb 2012 07:47:45 GMT]]></title><description><![CDATA[<p>@TE: einen String in einen COLOR_CODE zu &quot;schieben&quot; sieht reichlich unintuitiv aus. Wozu willst du sowas machen? Operatoren zu überladen nur damit man operatoren überladen hat ist nicht der richtige Weg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2185029</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2185029</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Fri, 24 Feb 2012 07:47:45 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von operator&amp;lt;&amp;lt; on Fri, 24 Feb 2012 09:26:02 GMT]]></title><description><![CDATA[<p>Das sieht nicht nur unintuitiv aus, ist auch reichlich unflexibel (immer std::cout).</p>
<p>Möchtest Du nicht in Wirklichkeit einen Colorcode in einen Stream schieben?</p>
<p>Oder möchtest Du so eine Art Streamklasse selbst schreiben?</p>
<p>EDIT:<br />
Wenn ich die Quelltextkommentare richtig verstehe, erwartest Du bei myClass &lt;&lt; COLOR_CODE &lt;&lt; &quot;string&quot;, dass ein operator&lt;&lt; mit zwei Parametern color_code und string aufgerufen wird? Da bist Du völlig auf dem Holzweg:</p>
<pre><code class="language-cpp">// wird aufgerufen bei myObj &lt;&lt; white
MyClass &amp;operator&lt;&lt;( MyClass&amp; myObj, color_code const&amp; cc )
{
    myObj.setfont(cc);
    return myObj;
}

// wird aufgerufen bei (Rückgabe von oben) &lt;&lt; &quot;text&quot;
MyClass &amp;operator&lt;&lt;( MyClass&amp; myObj, string cvonst&amp; text )
{
    myObj.print(text);
    return myObj;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2185069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2185069</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Fri, 24 Feb 2012 09:26:02 GMT</pubDate></item></channel></rss>