<?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[&amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse?]]></title><description><![CDATA[<p>Hey C++ler,</p>
<p>ich möchte eine Varibale einer Klasse in aus deren privat bereich ausgeben.<br />
Dafür wollte ich folgendes tun:</p>
<pre><code class="language-cpp">class User
{
strin name;
};

User Test;

ostream&amp; operator&lt;&lt;(ostream&amp; os,const int&amp;name)
{
	return os &lt;&lt;&quot;Benutzername: &quot;&lt;&lt;Test.name&lt;&lt;endl;
}
</code></pre>
<p>Leider funzt das nicht, da name ja privat ist und daher nicht auf es zugegriffen werden kann. Wie bekomme ich es hin, dass ich auch private Member ausgeben kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/294809/lt-lt-ostream-operator-für-private-objekt-einer-klasse</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 18:11:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/294809.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Nov 2011 20:04:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse? on Tue, 01 Nov 2011 20:04:21 GMT]]></title><description><![CDATA[<p>Hey C++ler,</p>
<p>ich möchte eine Varibale einer Klasse in aus deren privat bereich ausgeben.<br />
Dafür wollte ich folgendes tun:</p>
<pre><code class="language-cpp">class User
{
strin name;
};

User Test;

ostream&amp; operator&lt;&lt;(ostream&amp; os,const int&amp;name)
{
	return os &lt;&lt;&quot;Benutzername: &quot;&lt;&lt;Test.name&lt;&lt;endl;
}
</code></pre>
<p>Leider funzt das nicht, da name ja privat ist und daher nicht auf es zugegriffen werden kann. Wie bekomme ich es hin, dass ich auch private Member ausgeben kann?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138957</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138957</guid><dc:creator><![CDATA[Golfi1812]]></dc:creator><pubDate>Tue, 01 Nov 2011 20:04:21 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse? on Tue, 01 Nov 2011 20:08:04 GMT]]></title><description><![CDATA[<p>Operator als friend implementieren</p>
<p>greetz KN4CK3R</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138960</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138960</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Tue, 01 Nov 2011 20:08:04 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse? on Tue, 01 Nov 2011 20:29:25 GMT]]></title><description><![CDATA[<p>oder über einen getter zugriff geben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138971</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138971</guid><dc:creator><![CDATA[getter]]></dc:creator><pubDate>Tue, 01 Nov 2011 20:29:25 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse? on Tue, 01 Nov 2011 20:39:17 GMT]]></title><description><![CDATA[<p>Wie implementiere ich den operator als friend?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138975</guid><dc:creator><![CDATA[Golfi1812]]></dc:creator><pubDate>Tue, 01 Nov 2011 20:39:17 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;lt;&amp;lt; ostream operator für private Objekt einer Klasse? on Tue, 01 Nov 2011 20:52:58 GMT]]></title><description><![CDATA[<p><a href="http://ideone.com/fvuXI" rel="nofollow">http://ideone.com/fvuXI</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2138984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2138984</guid><dc:creator><![CDATA[KN4CK3R]]></dc:creator><pubDate>Tue, 01 Nov 2011 20:52:58 GMT</pubDate></item></channel></rss>