<?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[Referenz als Defaultparameter]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>Ist es möglich, eine Referenz die ein Funktionsparameter ist, einen Defaultwert zuzuweisen?</p>
<p>Fiktives nicht funktionierendes Beispiel:</p>
<pre><code class="language-cpp">std::vector&lt; std::string &gt; &amp;ref = 0
</code></pre>
<p>Geht soetwas?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/149011/referenz-als-defaultparameter</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 01:40:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/149011.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 01 Jun 2006 11:58:08 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Referenz als Defaultparameter on Thu, 01 Jun 2006 11:58:08 GMT]]></title><description><![CDATA[<p>Hallo Leute!</p>
<p>Ist es möglich, eine Referenz die ein Funktionsparameter ist, einen Defaultwert zuzuweisen?</p>
<p>Fiktives nicht funktionierendes Beispiel:</p>
<pre><code class="language-cpp">std::vector&lt; std::string &gt; &amp;ref = 0
</code></pre>
<p>Geht soetwas?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1069496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1069496</guid><dc:creator><![CDATA[Delryn]]></dc:creator><pubDate>Thu, 01 Jun 2006 11:58:08 GMT</pubDate></item><item><title><![CDATA[Reply to Referenz als Defaultparameter on Thu, 01 Jun 2006 12:09:59 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Da eine Referenz immer auf ein gültiges Objekt zeigen muß, Nein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1069510</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1069510</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Thu, 01 Jun 2006 12:09:59 GMT</pubDate></item><item><title><![CDATA[Reply to Referenz als Defaultparameter on Thu, 01 Jun 2006 12:18:32 GMT]]></title><description><![CDATA[<p>Als Funktionsparameter (oder auch von Methoden) kannst du aber z.B.</p>
<pre><code class="language-cpp">void f(const std::string &amp;str = std::string());
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">static std::vector&lt; std::string &gt; st_vec;
void f(std::vector&lt; std::string &gt; &amp;vec = st_vec)
</code></pre>
<p>deklarieren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1069522</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1069522</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Thu, 01 Jun 2006 12:18:32 GMT</pubDate></item><item><title><![CDATA[Reply to Referenz als Defaultparameter on Thu, 01 Jun 2006 12:20:58 GMT]]></title><description><![CDATA[<p>Delryn schrieb:</p>
<blockquote>
<p>Hallo Leute!</p>
<p>Ist es möglich, eine Referenz die ein Funktionsparameter ist, einen Defaultwert zuzuweisen?</p>
<p>Fiktives nicht funktionierendes Beispiel:</p>
<pre><code class="language-cpp">std::vector&lt; std::string &gt; &amp;ref = 0
</code></pre>
<p>Geht soetwas?</p>
</blockquote>
<p>sofern der initialisierunsgausdruck dann ein lvalue des entsprechenden typs ist (oder implizit in diesen gewandelt werden kann), kein problem. für die konstante 0 trifft das allerdings niemals zu <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 />
gewöhnlich macht man das mit referenzen auf const, denn dann kann man temporaries benutzen - bei referenzen auf non-const ist es eher schwierig, einen sinnvollen ausdruck zu finden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1069527</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1069527</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 01 Jun 2006 12:20:58 GMT</pubDate></item></channel></rss>