<?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[stream will noch nicht so, wie ich will]]></title><description><![CDATA[<p>moin,<br />
ich habe eine Klasse &quot;class myStream&quot; die auch fröhlich streamt. Folgende Konstruktion stößt auf einen Compilererror unter gcc:<br />
myStream() &lt;&lt; &quot; hallo &quot;; // Fehlermeldung no match for 'operator&lt;&lt;' in 'myStream() &lt;&lt; &quot; hallo &quot;'<br />
Brauche einen Tip.<br />
tschüß<br />
Troll.Soft</p>
<pre><code>#include &lt;sstream&gt; 
#include &lt;iostream&gt;

using namespace std;

class myStream; 
myStream&amp; my(myStream&amp;);

class myStream 
{ 
public: 
	myStream()	{} 	
	~myStream()	{	cout &lt;&lt; &quot;start &quot; &lt;&lt; o.str() &lt;&lt; &quot; ende&quot;;	} 

	friend myStream&amp; my(myStream&amp; stream)	{	stream &lt;&lt; &quot;&lt;myStream&gt;&quot;;	return stream;	} 

	friend myStream&amp; operator&lt;&lt;(myStream&amp; stream, const char* S)	{	stream.o &lt;&lt; S;	return stream;	} 

	string str() const	{	return o.str();	}
private:
	ostringstream o;
}; 

// manipulator function 
inline myStream&amp; operator&lt;&lt;(myStream&amp; stream, myStream&amp; (*function)(myStream&amp;) ) 
{	return (*function)(stream);	} 

int main() 
{
	myStream MyStream; 

	MyStream	&lt;&lt; &quot; hallo &quot; &lt;&lt; my &lt;&lt; &quot; hallo &quot; &lt;&lt; my;
	myStream()	&lt;&lt; &quot; hallo &quot; &lt;&lt; my &lt;&lt; &quot; hallo &quot; &lt;&lt; my;	// mit VC2008 ok  // mit gcc error: no match for 'operator&lt;&lt;' in 'myStream() &lt;&lt; &quot; hallo &quot;'

	cout &lt;&lt; MyStream.str();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/267460/stream-will-noch-nicht-so-wie-ich-will</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 16:32:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/267460.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 May 2010 07:45:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to stream will noch nicht so, wie ich will on Tue, 25 May 2010 07:45:28 GMT]]></title><description><![CDATA[<p>moin,<br />
ich habe eine Klasse &quot;class myStream&quot; die auch fröhlich streamt. Folgende Konstruktion stößt auf einen Compilererror unter gcc:<br />
myStream() &lt;&lt; &quot; hallo &quot;; // Fehlermeldung no match for 'operator&lt;&lt;' in 'myStream() &lt;&lt; &quot; hallo &quot;'<br />
Brauche einen Tip.<br />
tschüß<br />
Troll.Soft</p>
<pre><code>#include &lt;sstream&gt; 
#include &lt;iostream&gt;

using namespace std;

class myStream; 
myStream&amp; my(myStream&amp;);

class myStream 
{ 
public: 
	myStream()	{} 	
	~myStream()	{	cout &lt;&lt; &quot;start &quot; &lt;&lt; o.str() &lt;&lt; &quot; ende&quot;;	} 

	friend myStream&amp; my(myStream&amp; stream)	{	stream &lt;&lt; &quot;&lt;myStream&gt;&quot;;	return stream;	} 

	friend myStream&amp; operator&lt;&lt;(myStream&amp; stream, const char* S)	{	stream.o &lt;&lt; S;	return stream;	} 

	string str() const	{	return o.str();	}
private:
	ostringstream o;
}; 

// manipulator function 
inline myStream&amp; operator&lt;&lt;(myStream&amp; stream, myStream&amp; (*function)(myStream&amp;) ) 
{	return (*function)(stream);	} 

int main() 
{
	myStream MyStream; 

	MyStream	&lt;&lt; &quot; hallo &quot; &lt;&lt; my &lt;&lt; &quot; hallo &quot; &lt;&lt; my;
	myStream()	&lt;&lt; &quot; hallo &quot; &lt;&lt; my &lt;&lt; &quot; hallo &quot; &lt;&lt; my;	// mit VC2008 ok  // mit gcc error: no match for 'operator&lt;&lt;' in 'myStream() &lt;&lt; &quot; hallo &quot;'

	cout &lt;&lt; MyStream.str();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1902128</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902128</guid><dc:creator><![CDATA[Troll.Soft]]></dc:creator><pubDate>Tue, 25 May 2010 07:45:28 GMT</pubDate></item><item><title><![CDATA[Reply to stream will noch nicht so, wie ich will on Tue, 25 May 2010 07:58:54 GMT]]></title><description><![CDATA[<p>Weil myStream() ein Funktionsaufruf ist. Und keine Ueberladung existiert, die mittels &lt;&lt; irgendwas in die Funktion piped.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902130</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Tue, 25 May 2010 07:58:54 GMT</pubDate></item><item><title><![CDATA[Reply to stream will noch nicht so, wie ich will on Tue, 25 May 2010 08:44:26 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Weil myStream() ein Funktionsaufruf ist. Und keine Ueberladung existiert, die mittels &lt;&lt; irgendwas in die Funktion piped.</p>
</blockquote>
<p>Aber es muss eine Trick geben, denn wenn ich direkt von ostringstream ableite meckert gcc nicht mehr über &quot;myStream() &lt;&lt; my;&quot;, gibt aber ein Warnung heraus.<br />
Man braucht also noch einen Trick.<br />
Hier ist der Code nur mit Warnung:</p>
<pre><code>#include &lt;sstream&gt; 
#include &lt;iostream&gt;

using namespace std;

class myStream; 
myStream&amp; my(myStream&amp;);

class myStream	:	public ostringstream
{ 
public: 
	myStream()	:	ostringstream()	{} 	
	~myStream()	{	cout &lt;&lt; &quot;  start &quot; &lt;&lt; str() &lt;&lt; &quot; ende  &quot;;	} 

	friend myStream&amp; my(myStream&amp; stream)	{	stream &lt;&lt; &quot;&lt;myStream&gt;&quot;;	return stream;	} 
}; 

// manipulator function 
inline myStream&amp; operator&lt;&lt;(myStream&amp; stream, myStream&amp; (*function)(myStream&amp;) ) 
{	return (*function)(stream);	} 

int main() 
{
	myStream()	&lt;&lt; my;	//	warning: the address of 'myStream&amp; my(myStream&amp;)' will always evaluate as 'true'
}
</code></pre>
<p>tschüß<br />
Troll.Soft</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902165</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902165</guid><dc:creator><![CDATA[Troll.Soft]]></dc:creator><pubDate>Tue, 25 May 2010 08:44:26 GMT</pubDate></item><item><title><![CDATA[Reply to stream will noch nicht so, wie ich will on Tue, 25 May 2010 09:17:51 GMT]]></title><description><![CDATA[<p>Meine erste Erklaerung ist wahrscheinlich falsch. Jedoch funktioniert dein zweites Beispiel auch nicht korrekt, bei mir ist &lt;stream&gt; nicht in der Ausgabe zwischen start und ende. Was den Trick betrifft: Ich wuerde nie so programmieren. Einfach Konstruktion und Benutzung des Objektes trennen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902175</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Tue, 25 May 2010 09:17:51 GMT</pubDate></item><item><title><![CDATA[Reply to stream will noch nicht so, wie ich will on Tue, 25 May 2010 09:20:45 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>bei mir ist &lt;stream&gt; nicht in der Ausgabe zwischen start und ende.</p>
</blockquote>
<p>Ja, da kommt die Warnung zum Tragen und es wird nur &quot;true&quot; ausgegeben.<br />
Ich will ja nicht unbedingt von ostringstream ableiten. Mir reicht der Trick mit dem ostringstream diese Konstruktion &quot;myStream()&quot; zum Laufen bringt.</p>
<p>tschüß<br />
Troll.Soft</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1902182</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1902182</guid><dc:creator><![CDATA[Troll.Soft]]></dc:creator><pubDate>Tue, 25 May 2010 09:20:45 GMT</pubDate></item></channel></rss>