<?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[CString Aufklärung]]></title><description><![CDATA[<p>ich würde mal gerne wissen was bei der zuweisung passiert:</p>
<pre><code>CString s1;
CString s2;

s2=&quot;hallo&quot;;

s1 = s2;
</code></pre>
<p>wird hier nur der Pointer an s1 gegeben oder wird s2 in s1 kopiert (ich glaub hab ich irgendwo gelesen)</p>
<p>und was passiert hier:</p>
<pre><code>CString s1;
char* s2;
wchar_t s3[20];

s2 = new char[20];
s2 = &quot;test2&quot;;

s3=&quot;test3&quot;;

s1 = s2;
s1 = s3;

delete[] s2;
</code></pre>
<p>gleiche Frage wie oben Pointer übergabe oder Copy?</p>
<p>Und was passiert in diesem falle:</p>
<pre><code>//deklaration:
void useString(CString s1);
</code></pre>
<pre><code>useString(s3);
</code></pre>
<p>wird nun in der funktion s3 in s1 kopiert oder nur die Pointer übergeben?<br />
freigabe s1 am ende der Funktion?</p>
<pre><code>useString(&quot;Hallo&quot;); // Konstante angelegt in s1?
</code></pre>
<p>und wie verhält sich das ganze mit CString als Rückgabewerten in Funktionen</p>
<pre><code>//deklaration:
CString GetString();
</code></pre>
<pre><code>CString GetString()
{
  CString s1;

  s1=&quot;Hallo&quot;
  return s1; 
}
</code></pre>
<pre><code>CString s2;
s2 = GetString();
</code></pre>
<p>geht sowas? und was passiert intern (also wird bevor s1 aufgelöst wird s1 in s2 kopiert?)</p>
<p>Was will mir die MSDN damit sagen:</p>
<blockquote>
<p>This assignment (=) operator reinitializes an existing CString object with new data. If the destination string — that is, the left side — is already large enough to store the new data, no new memory allocation is performed. Be aware that memory exceptions may occur whenever you use the assignment operator because new storage is often allocated to hold the resulting CString object.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/topic/159860/cstring-aufklärung</link><generator>RSS for Node</generator><lastBuildDate>Tue, 28 Jul 2026 09:22:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/159860.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 19 Sep 2006 15:21:25 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CString Aufklärung on Tue, 19 Sep 2006 15:33:37 GMT]]></title><description><![CDATA[<p>ich würde mal gerne wissen was bei der zuweisung passiert:</p>
<pre><code>CString s1;
CString s2;

s2=&quot;hallo&quot;;

s1 = s2;
</code></pre>
<p>wird hier nur der Pointer an s1 gegeben oder wird s2 in s1 kopiert (ich glaub hab ich irgendwo gelesen)</p>
<p>und was passiert hier:</p>
<pre><code>CString s1;
char* s2;
wchar_t s3[20];

s2 = new char[20];
s2 = &quot;test2&quot;;

s3=&quot;test3&quot;;

s1 = s2;
s1 = s3;

delete[] s2;
</code></pre>
<p>gleiche Frage wie oben Pointer übergabe oder Copy?</p>
<p>Und was passiert in diesem falle:</p>
<pre><code>//deklaration:
void useString(CString s1);
</code></pre>
<pre><code>useString(s3);
</code></pre>
<p>wird nun in der funktion s3 in s1 kopiert oder nur die Pointer übergeben?<br />
freigabe s1 am ende der Funktion?</p>
<pre><code>useString(&quot;Hallo&quot;); // Konstante angelegt in s1?
</code></pre>
<p>und wie verhält sich das ganze mit CString als Rückgabewerten in Funktionen</p>
<pre><code>//deklaration:
CString GetString();
</code></pre>
<pre><code>CString GetString()
{
  CString s1;

  s1=&quot;Hallo&quot;
  return s1; 
}
</code></pre>
<pre><code>CString s2;
s2 = GetString();
</code></pre>
<p>geht sowas? und was passiert intern (also wird bevor s1 aufgelöst wird s1 in s2 kopiert?)</p>
<p>Was will mir die MSDN damit sagen:</p>
<blockquote>
<p>This assignment (=) operator reinitializes an existing CString object with new data. If the destination string — that is, the left side — is already large enough to store the new data, no new memory allocation is performed. Be aware that memory exceptions may occur whenever you use the assignment operator because new storage is often allocated to hold the resulting CString object.</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1140502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140502</guid><dc:creator><![CDATA[Rio1]]></dc:creator><pubDate>Tue, 19 Sep 2006 15:33:37 GMT</pubDate></item><item><title><![CDATA[Reply to CString Aufklärung on Tue, 19 Sep 2006 15:34:47 GMT]]></title><description><![CDATA[<p>CString ist kein standard C++ --&gt; falsches Forum</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140509</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140509</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Tue, 19 Sep 2006 15:34:47 GMT</pubDate></item><item><title><![CDATA[Reply to CString Aufklärung on Tue, 19 Sep 2006 15:47:55 GMT]]></title><description><![CDATA[<p>dann muss ichs wohl ins MFC kopieren ...</p>
<p><em>PS: das ist aber dann kein crossposting mehr</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140516</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140516</guid><dc:creator><![CDATA[Rio1]]></dc:creator><pubDate>Tue, 19 Sep 2006 15:47:55 GMT</pubDate></item><item><title><![CDATA[Reply to CString Aufklärung on Wed, 20 Sep 2006 10:39:16 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=1" rel="nofollow">MFC (Visual C++)</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1140993</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1140993</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Wed, 20 Sep 2006 10:39:16 GMT</pubDate></item><item><title><![CDATA[Reply to CString Aufklärung on Wed, 20 Sep 2006 10:55:02 GMT]]></title><description><![CDATA[<p>CString verhält sich so wie es sein soll. Wenn du einem CString-Objekt einen normalen char-Pointer zuweist kann er gar nicht anders als die eigentliche Zeichenkette zu kopieren.</p>
<p>Das bei der Zuweisung zwischen zwei CStrings der Pointer zugewiesen wird ist eine interne Optimierung, die nur dann zuverlässig funktionieren kann, wenn garantiert ist, dass die CStrings den von ihnen benötigten Speicher verwalten (anlegen/löschen).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141003</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141003</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Wed, 20 Sep 2006 10:55:02 GMT</pubDate></item><item><title><![CDATA[Reply to CString Aufklärung on Wed, 20 Sep 2006 13:43:32 GMT]]></title><description><![CDATA[<p><a href="http://c-plusplus.net/forum/viewtopic-var-t-is-159861.html" rel="nofollow">hier</a> geht's weiter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1141176</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1141176</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Wed, 20 Sep 2006 13:43:32 GMT</pubDate></item></channel></rss>