<?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; richtig überladen?]]></title><description><![CDATA[<p>Mein Compiler gibt mir bei folgenden Code:</p>
<pre><code class="language-cpp">ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src)
{
	out&lt;&lt;src.m_Filename;
	return out;
};
</code></pre>
<p>diese Warnung aus:</p>
<blockquote>
<p>Warning 1 warning C4717: 'Vertexwahn::Exception::operator&lt;&lt;' : recursive on all control paths, function will cause runtime stack overflow</p>
</blockquote>
<p>m_Filename ist ein std::string... mmh... was mache ich da falsch?<br />
ich verstehe die Warnung des Compilers nicht - warum rekursiv? ich rufe ja da nicht wieder die gleiche Methode auf, sonderen eine Methode die einen String frist...?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/163328/operator-lt-lt-richtig-überladen</link><generator>RSS for Node</generator><lastBuildDate>Sun, 13 Sep 2026 00:23:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/163328.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Oct 2006 14:45:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 14:45:23 GMT]]></title><description><![CDATA[<p>Mein Compiler gibt mir bei folgenden Code:</p>
<pre><code class="language-cpp">ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src)
{
	out&lt;&lt;src.m_Filename;
	return out;
};
</code></pre>
<p>diese Warnung aus:</p>
<blockquote>
<p>Warning 1 warning C4717: 'Vertexwahn::Exception::operator&lt;&lt;' : recursive on all control paths, function will cause runtime stack overflow</p>
</blockquote>
<p>m_Filename ist ein std::string... mmh... was mache ich da falsch?<br />
ich verstehe die Warnung des Compilers nicht - warum rekursiv? ich rufe ja da nicht wieder die gleiche Methode auf, sonderen eine Methode die einen String frist...?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163133</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163133</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 14:45:23 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 14:52:16 GMT]]></title><description><![CDATA[<p>du hast FileNotFoundException von std::string abgelitten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163139</guid><dc:creator><![CDATA[wisser]]></dc:creator><pubDate>Sat, 28 Oct 2006 14:52:16 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:00:19 GMT]]></title><description><![CDATA[<p>wisser schrieb:</p>
<blockquote>
<p>du hast FileNotFoundException von std::string abgelitten</p>
</blockquote>
<pre><code class="language-cpp">class FileNotFoundException
{
public:
	FileNotFoundException(string Filename);
	FileNotFoundException(const FileNotFoundException &amp;src);

	friend ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src);
private:

	FileNotFoundException&amp; operator=(const FileNotFoundException &amp;src);

	string m_Filename;	// Dateiname der Datei, die nicht gefunden wurde
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1163143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163143</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:00:19 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:02:55 GMT]]></title><description><![CDATA[<p>Bitte gib uns ein vollständigen, aber minimalen Sourcecode der die Warnung erzeugt und sag welchen Compiler du verwendest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163144</guid><dc:creator><![CDATA[Hellmut]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:02:55 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:08:47 GMT]]></title><description><![CDATA[<p>FileNotFoundException.h:</p>
<pre><code class="language-cpp">#ifndef FileNotFoundException_h
#define FileNotFoundException_h

#include &lt;iostream&gt;
using namespace std;  // &lt;- pfui! ;)

namespace Vertexwahn
{
	namespace Exception
	{
		/// Diese Exception wird geworfen, wenn eine Datei nicht gefunden werden konnte.
		class FileNotFoundException
		{
		public:
			FileNotFoundException(string Filename);
			FileNotFoundException(const FileNotFoundException &amp;src);

			friend ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src);
		private:

			FileNotFoundException&amp; operator=(const FileNotFoundException &amp;src);

			string m_Filename;	// Dateiname der Datei, die nicht gefunden wurde
		};

		ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src);
	} // namespace Exception
} // namespace Vertexwahn

#endif
</code></pre>
<p>FileNotFoundException.cpp:</p>
<pre><code class="language-cpp">#include &quot;FileNotFoundException.h&quot;

namespace Vertexwahn
{
	namespace Exception
	{
		FileNotFoundException::FileNotFoundException(string Filename) : m_Filename(Filename)
		{
		}

		FileNotFoundException::FileNotFoundException(const FileNotFoundException &amp;src) 
		{
			m_Filename = src.m_Filename;
		}

		FileNotFoundException&amp; FileNotFoundException::operator=(const FileNotFoundException &amp;src) 
		{
			return *this;
		}

		ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src)
		{
			out&lt;&lt;src.m_Filename;
			return out;
		};
	}
}
</code></pre>
<p>ich verwende MS Visual Studio 2005</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163149</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163149</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:08:47 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:09:50 GMT]]></title><description><![CDATA[<p>Bitte mit main Funktion und alles in einer Datei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163150</guid><dc:creator><![CDATA[Hellmut]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:09:50 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:15:01 GMT]]></title><description><![CDATA[<p>main.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
using namespace std;

namespace Vertexwahn
{
	namespace Exception
	{
		/// Diese Exception wird geworfen, wenn eine Datei nicht gefunden werden konnte.
		class FileNotFoundException
		{
		public:
			FileNotFoundException(string Filename);
			FileNotFoundException(const FileNotFoundException &amp;src);

			friend ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src);
		private:

			FileNotFoundException&amp; operator=(const FileNotFoundException &amp;src);

			string m_Filename;    // Dateiname der Datei, die nicht gefunden wurde
		};

		ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src);

		FileNotFoundException::FileNotFoundException(string Filename) : m_Filename(Filename)
		{
		}

		FileNotFoundException::FileNotFoundException(const FileNotFoundException &amp;src)
		{
			m_Filename = src.m_Filename;
		}

		FileNotFoundException&amp; FileNotFoundException::operator=(const FileNotFoundException &amp;src)
		{
			return *this;
		}

		ostream&amp; operator&lt;&lt;(ostream &amp;out, const FileNotFoundException &amp;src)
		{
			out&lt;&lt;src.m_Filename;
			return out;
		}; 
	} // namespace Exception
} // namespace Vertexwahn

int main()
{
	cout&lt;&lt;&quot;Hallo Welt!&quot;&lt;&lt;endl;
}
</code></pre>
<p>Fehlermeldung:</p>
<blockquote>
<p>Warning 1 warning C4717: 'Vertexwahn::Exception::operator&lt;&lt;' : recursive on all control paths, function will cause runtime stack overflow main.cpp 43</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1163152</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163152</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:15:01 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:21:26 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;string&gt;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1163153</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163153</guid><dc:creator><![CDATA[Hellmut]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:21:26 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:22:53 GMT]]></title><description><![CDATA[<p>#include &lt;string&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163154</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:29:46 GMT]]></title><description><![CDATA[<p>cool jetzt ist die Warnung weg <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /><br />
aber warum? er hätte doch einen Fehler melden müssen, weil er string nicht kennt... oder?</p>
<p>g++ übersetzt es ohne mekern</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163155</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163155</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:29:46 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:36:49 GMT]]></title><description><![CDATA[<p>wenn man den konstruktor entfernt lässt es sich gar nicht kompilieren.</p>
<p>das heißt also er baut über den Konstruktor ein FileNotFoundException und somit ist es rekursiv. mach den konstruktor mal explicit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163164</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163164</guid><dc:creator><![CDATA[asndof]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:36:49 GMT</pubDate></item><item><title><![CDATA[Reply to operator&amp;lt;&amp;lt; richtig überladen? on Sat, 28 Oct 2006 15:58:00 GMT]]></title><description><![CDATA[<p>oh - jetzt wird mir das problem erst klar... implizite Typumwandlung.... mmh... ja das ist böse <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1163178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1163178</guid><dc:creator><![CDATA[Vertexwahn]]></dc:creator><pubDate>Sat, 28 Oct 2006 15:58:00 GMT</pubDate></item></channel></rss>