<?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[operator&amp;lt;&amp;lt; für template Klasse überladen]]></title><description><![CDATA[<p>Hallo ,</p>
<p>ich habe eine template Klasse Kreis , leider krieg ich bei meinem operator immer eine Fehlermeldung. Ist die Syntax falsch?</p>
<p>template&lt;class T,class S&gt;class Kreis { // template fuer mehrere Datentypen<br />
private:<br />
T m_x; //x-Koordinate Mittelpunkt<br />
T m_y; //y-Koordinate Mittelpunkt<br />
S rad; //Radius</p>
<p>...<br />
};</p>
<p>Kreis&lt;class T,class S&gt; ostream&amp; operator&lt;&lt;(ostream&amp; os, const Kreis&lt;class T,class S&gt;&amp; k) {<br />
os &lt;&lt; &quot;Mittelpunkt: (&quot; &lt;&lt; k.m_x &lt;&lt; &quot;,&quot; &lt;&lt; k.m_y &lt;&lt; &quot;), Radius: &quot; &lt;&lt; k.rad;<br />
return os;<br />
}</p>
<p>Vielen Dank für Eure Hilfe,</p>
<p>Carolin[cpp]</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/256589/operator-lt-lt-für-template-klasse-überladen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 11 Sep 2026 05:59:16 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/256589.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 15 Dec 2009 10:45:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 10:45:44 GMT]]></title><description><![CDATA[<p>Hallo ,</p>
<p>ich habe eine template Klasse Kreis , leider krieg ich bei meinem operator immer eine Fehlermeldung. Ist die Syntax falsch?</p>
<p>template&lt;class T,class S&gt;class Kreis { // template fuer mehrere Datentypen<br />
private:<br />
T m_x; //x-Koordinate Mittelpunkt<br />
T m_y; //y-Koordinate Mittelpunkt<br />
S rad; //Radius</p>
<p>...<br />
};</p>
<p>Kreis&lt;class T,class S&gt; ostream&amp; operator&lt;&lt;(ostream&amp; os, const Kreis&lt;class T,class S&gt;&amp; k) {<br />
os &lt;&lt; &quot;Mittelpunkt: (&quot; &lt;&lt; k.m_x &lt;&lt; &quot;,&quot; &lt;&lt; k.m_y &lt;&lt; &quot;), Radius: &quot; &lt;&lt; k.rad;<br />
return os;<br />
}</p>
<p>Vielen Dank für Eure Hilfe,</p>
<p>Carolin[cpp]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822712</guid><dc:creator><![CDATA[fischldi]]></dc:creator><pubDate>Tue, 15 Dec 2009 10:45:44 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 10:47:59 GMT]]></title><description><![CDATA[<p>Und welche Fehlermeldung kriegst du?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822714</guid><dc:creator><![CDATA[fehlermelder]]></dc:creator><pubDate>Tue, 15 Dec 2009 10:47:59 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 10:48:42 GMT]]></title><description><![CDATA[<p>error: expected initializer before â&amp;â token</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822716</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822716</guid><dc:creator><![CDATA[fischldi]]></dc:creator><pubDate>Tue, 15 Dec 2009 10:48:42 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 11:18:27 GMT]]></title><description><![CDATA[<p>Deine Syntax ist ziemlich durcheinander. So geht das:</p>
<pre><code class="language-cpp">template&lt;class T,class S&gt;class Kreis { // template fuer mehrere Datentypen
private:
T m_x; //x-Koordinate Mittelpunkt
T m_y; //y-Koordinate Mittelpunkt
S rad; //Radius

  friend ostream&amp; operator&lt;&lt; &lt;T,S&gt;(ostream&amp; os, const Kreis&lt;T,S&gt;&amp; k);
};

template&lt;class T,class S&gt; ostream&amp; operator&lt;&lt;(ostream&amp; os, const Kreis&lt;T,S&gt;&amp; k) {
 os &lt;&lt; &quot;Mittelpunkt: (&quot; &lt;&lt; k.m_x &lt;&lt; &quot;,&quot; &lt;&lt; k.m_y &lt;&lt; &quot;), Radius: &quot; &lt;&lt; k.rad;
return os;
}
</code></pre>
<p>Guck dir genau an, wie ich das im Gegensatz zu dir gemacht habe. Wenn du das verstehst, hast du viel über Templates gelernt. Zur Not frag nach, wenn es unklar ist.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822727</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822727</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 15 Dec 2009 11:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 11:50:17 GMT]]></title><description><![CDATA[<p>Der Operator soll weder friend noch Elementfunktion sein ... wie würde das denn aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822745</guid><dc:creator><![CDATA[fischldi]]></dc:creator><pubDate>Tue, 15 Dec 2009 11:50:17 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 11:55:04 GMT]]></title><description><![CDATA[<p>fischldi schrieb:</p>
<blockquote>
<p>Der Operator soll weder friend noch Elementfunktion sein ... wie würde das denn aussehen?</p>
</blockquote>
<p>Er muss aber friend sein, wenn du versuchst wie in deinem Code auf private Member direkt zuzugreifen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822751</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822751</guid><dc:creator><![CDATA[polomade]]></dc:creator><pubDate>Tue, 15 Dec 2009 11:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 14:09:45 GMT]]></title><description><![CDATA[<p>fischldi schrieb:</p>
<blockquote>
<p>Der Operator soll weder friend noch Elementfunktion sein ... wie würde das denn aussehen?</p>
</blockquote>
<p>Mit öffentlichen get-Funktionen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1822862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822862</guid><dc:creator><![CDATA[joomoo]]></dc:creator><pubDate>Tue, 15 Dec 2009 14:09:45 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; für template Klasse überladen on Tue, 15 Dec 2009 15:44:55 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">template&lt;class T,class S&gt;
class Kreis { 
public:
	std::ostream &amp; print(std::ostream&amp; os)
	{
		os &lt;&lt; &quot;Mittelpunkt: (&quot; &lt;&lt; k.m_x &lt;&lt; &quot;,&quot; &lt;&lt; k.m_y &lt;&lt; &quot;), Radius: &quot; &lt;&lt; k.rad;
		return os;
	}
private:
	T m_x; //x-Koordinate Mittelpunkt
	T m_y; //y-Koordinate Mittelpunkt
	S rad; //Radius
};

template&lt;class T,class S&gt; 
std::ostream &amp; operator &lt;&lt; (std::ostream&amp; os, const Kreis&lt;T,S&gt;&amp; k)
{
	return k.print(os);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1822937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1822937</guid><dc:creator><![CDATA[brotbernd]]></dc:creator><pubDate>Tue, 15 Dec 2009 15:44:55 GMT</pubDate></item></channel></rss>