<?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[fkt (&amp;amp;string) vs fkt (string)]]></title><description><![CDATA[<p>Also wie der Titel schon sagt... Ist es immer performanter nur einen Pointer des Strings zu übergeben oder gibt es Fälle, in denen es sinnvoller ist, den &quot;richtigen&quot; String zu übergeben?</p>
<p>bsp.:</p>
<pre><code class="language-cpp">RealQuery (&quot;SELECT * FROM asd;&quot;);
//bzw.:
const string *a = new string (&quot;SELECT * FROM asd;&quot;);
RealQuery (a); //delete a;
</code></pre>
<p>Danke...</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/203981/fkt-amp-string-vs-fkt-string</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 08:44:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/203981.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Jan 2008 19:13:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:35:36 GMT]]></title><description><![CDATA[<p>Also wie der Titel schon sagt... Ist es immer performanter nur einen Pointer des Strings zu übergeben oder gibt es Fälle, in denen es sinnvoller ist, den &quot;richtigen&quot; String zu übergeben?</p>
<p>bsp.:</p>
<pre><code class="language-cpp">RealQuery (&quot;SELECT * FROM asd;&quot;);
//bzw.:
const string *a = new string (&quot;SELECT * FROM asd;&quot;);
RealQuery (a); //delete a;
</code></pre>
<p>Danke...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445300</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:35:36 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:20:22 GMT]]></title><description><![CDATA[<p>Du übergibst einen Pointer und keine Referenz.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445304</guid><dc:creator><![CDATA[sw22]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:20:22 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:35:17 GMT]]></title><description><![CDATA[<p>joar - stimmt xD<br />
sry - war gerad noch wo anders im kopf ^^<br />
habs ma geändert... -.-</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445314</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:35:17 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:35:59 GMT]]></title><description><![CDATA[<p>Hem, ich glaube du bringst da was durcheinander. Nicht du als Aufrufer kannst entscheiden was du übergibst. RealQuery entscheidet nämlich was es haben will. Du übergibst aber zwei verschiedene Dinge.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445315</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445315</guid><dc:creator><![CDATA[Artchi]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:35:59 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:38:06 GMT]]></title><description><![CDATA[<p>Nein - das stimmt nicht... Die Fkt gibt es nicht -&gt; ich schreibe sie (die 'richtige' läuft im gleichen Thread ab und das wär ne sooo sehr von Vorteil)...<br />
Deshalb frage ich...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445317</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:38:06 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:41:08 GMT]]></title><description><![CDATA[<p>Du verwechselst trotzdem einiges. Vergiss die Übergabe per Zeiger, die ist hier nicht sinnvoll. Richtig (bzw. C++-ig) wäre, eine const-Referenz auf den String zu übergeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445319</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445319</guid><dc:creator><![CDATA[Konrad Rudolph]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:41:08 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:47:18 GMT]]></title><description><![CDATA[<p>hmm... ok - danke : &gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445324</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445324</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:47:18 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:50:59 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">RealQuery(const string&amp; query);

...

string bla(&quot;awer&quot;);
RealQuery(bla);
</code></pre>
<p>Lern mal den unterschied zwischen Pointer, Referenz und Wertübergabe, dann kannst du dir deine Frage selber beantworten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445328</guid><dc:creator><![CDATA[sw22]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:50:59 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:54:31 GMT]]></title><description><![CDATA[<p>@sw22: doof? Oo</p>
<p>Ich wollte wissen, was toller ist:</p>
<ol>
<li></li>
</ol>
<pre><code class="language-cpp">RealQuery(const string &amp; const query);
...
string bla(&quot;awer&quot;);
RealQuery(bla);
</code></pre>
<p><strong>oder</strong></p>
<ol start="2">
<li></li>
</ol>
<pre><code class="language-cpp">RealQuery(const string query);
...
string bla(&quot;awer&quot;);
RealQuery(bla);
</code></pre>
<p><strong>oder</strong></p>
<ol start="3">
<li></li>
</ol>
<pre><code class="language-cpp">RealQuery(const string * const query);
...
string bla(&quot;awer&quot;);
RealQuery(&amp;bla);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1445332</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445332</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:54:31 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 19:59:00 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>@sw22: doof? Oo</p>
</blockquote>
<p>Du Idiot hast alles durcheinander gebracht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445335</guid><dc:creator><![CDATA[sw22]]></dc:creator><pubDate>Mon, 28 Jan 2008 19:59:00 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 20:03:12 GMT]]></title><description><![CDATA[<p>Und was genau hab ich da falsch verstanden? Oo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445339</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 20:03:12 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 20:05:25 GMT]]></title><description><![CDATA[<p>Hirn - Gedächtnis? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445344</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445344</guid><dc:creator><![CDATA[sw22]]></dc:creator><pubDate>Mon, 28 Jan 2008 20:05:25 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 20:20:35 GMT]]></title><description><![CDATA[<p>Es geht nicht darum was &quot;toller&quot; ist. Es gibt da semantische Unterschiede. Eine Wertübergabe ist nunmal etwas anderes als eine Übergabe als Referenz. Beide haben ihr Einsatzgebiet. Soll deine Funktion den Übergebenen String nicht ändern, kannst du ihn entweder als Wert übergeben oder eine konstante Referenz übergeben. Wobei die beiden natürlich auch wieder unterschiedliche Bedeutungen haben. Bei der Wertübergabe wird der Wert in eine neue Variable kopiert (Aufruf des Kopierkonstruktors). Die interne Variable kann ohne Auswirkungen auf den übergebenen Parameter verändert werden. Die konstante Referenz ist nur ein Verweis auf den Parameter. Es darf nicht verändert auf das Objekt zugegriffen werden ,jedenfalls nicht semantisch verändernd. Auf mutable geh ich jetzt mal nicht ein.<br />
Die Zeigervariante ist in C++ dank Referenzen nicht nötig.</p>
<p>Gruß<br />
Don06</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445350</guid><dc:creator><![CDATA[Don06]]></dc:creator><pubDate>Mon, 28 Jan 2008 20:20:35 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 20:45:30 GMT]]></title><description><![CDATA[<p>Naja... Ich weiß, dass es sich bei sehr langen Strings auf jeden Fall lohnt eine Referenz oder einen Pointer zu übergeben anstatt dem String an sich, da er ja kopiert werden müsste (na schön - ab und zu optimiert das wohl der Compiler auch weg, wie ich mir hier schon anhören durfte, aber darum geht es jz nicht...).<br />
Ich wollte einfach nur wissen, was eben schneller geht - ob es vll irgend ne Grenze gibt, ab wo sich die Referenz oder der Pointer nicht mehr lohnt (mir klar, dass es da keine Grenze gibt, wie ab 63 Zeichen o.ä. aber vll kann mir ja wer bissl was genaueres sagen ^^</p>
<p>Bye</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445363</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 20:45:30 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 20:56:49 GMT]]></title><description><![CDATA[<p>Ich würde alles als Referenz, bzw. wenn NULL als Wert möglich sein soll Zeiger,<br />
übergeben, außer die Standardtypen wie char,int,float,short...<br />
double verwende ich praktisch nie, aber das übergäbe ich wieder als Referenz (&gt;4Byte)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445368</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445368</guid><dc:creator><![CDATA[Sososo]]></dc:creator><pubDate>Mon, 28 Jan 2008 20:56:49 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 21:19:44 GMT]]></title><description><![CDATA[<p>danke - endlich ma ne antwort, die mir was bringt : &gt; tytytyty ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445376</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445376</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 21:19:44 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 21:41:44 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>danke - endlich ma ne antwort, die mir was bringt : &gt; tytytyty ^^</p>
</blockquote>
<p>Ausführliche Zusammenfassung:</p>
<p>Ohne zulässigen NULL-Wert:<br />
Verwende sofern der Parameter nicht geändert werden soll bei eingebauten Datentypen Call by Value, bei Objekten Call by &quot;constant&quot; Referenz. Sobald der Parameter aber verändert werden soll: Call by Referenz.</p>
<p>Mit zulässigen NULL-Wert:<br />
Grundsätzlich gehen hier nur noch Pointerübergaben. Hier sollte man aber auch alles mit const deklarieren was nicht änderbar ist (Zeigeranteil, Objektanteil). Falls der Zeiger selbst änderbar sein sollte, würde ich ihn lieber per Zeigerreferenz (typ*&amp;) als per Zeiger auf Zeiger (typ**) übergeben, um die Zeigerarithmetik einfacher zu halten.</p>
<p>cu André</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445388</guid><dc:creator><![CDATA[asc]]></dc:creator><pubDate>Mon, 28 Jan 2008 21:41:44 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Mon, 28 Jan 2008 22:53:24 GMT]]></title><description><![CDATA[<p>Gut - so hatte ich das jetzt auch verstanden, danke noch mal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Bye</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445395</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Mon, 28 Jan 2008 22:53:24 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Tue, 29 Jan 2008 09:17:52 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<ol>
<li></li>
</ol>
<pre><code class="language-cpp">RealQuery(const string &amp; const query);
...
string bla(&quot;awer&quot;);
RealQuery(bla);
</code></pre>
</blockquote>
<p>Das wird dir der Compiler um die Ohren schmeißen. Du schreibst sowas wie &quot;eine konstante Referenz auf einen konstanten String&quot; - da aber Referenzen per definition nicht veränderbar sind, ist das zweite const nicht nur überflüssig sondern sogar verboten, weil einfach nicht Sprachbestandteil.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445499</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445499</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 29 Jan 2008 09:17:52 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Tue, 29 Jan 2008 13:12:11 GMT]]></title><description><![CDATA[<p>Naja - er ignoriert das überflüssige const einfach (und gibt ne Warnung aus, aber compiliert alles so, wie wenn da nur 1 const stehen würde ^^).<br />
Ansonsten hast du nat. recht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445638</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Tue, 29 Jan 2008 13:12:11 GMT</pubDate></item><item><title><![CDATA[Reply to fkt (&amp;amp;string) vs fkt (string) on Tue, 29 Jan 2008 14:50:09 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>Naja - er ignoriert das überflüssige const einfach (und gibt ne Warnung aus, aber compiliert alles so, wie wenn da nur 1 const stehen würde ^^).<br />
Ansonsten hast du nat. recht</p>
</blockquote>
<p>cv-qualifizierte Referenzen sind &quot;ill-formed&quot;, erfordern also eine Diagnose (nat. darf der Comniler danach machen was er will, eine Warnung genügt, nur hat das Resultat nichts mehr mit Standard-C++ zu tun). Nur wenn die cv-Qualifikation auf ein typedef oder einen Templateparameter erfolgt, der eine Referenz darstellt, wird die Qualifikation ignoriert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1445702</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1445702</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 29 Jan 2008 14:50:09 GMT</pubDate></item></channel></rss>