<?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[std::string Vererbung]]></title><description><![CDATA[<p>Vererbung: String von std::string</p>
<pre><code class="language-cpp">#include &lt;string&gt;

class String : public std::string
{

};

using std::cout;

int main(void)
{
	String Text; // Text(&quot;This&quot;); funktioniert auch nicht
	Text = &quot;this is my text!&quot;;
	return 0;
}
</code></pre>
<p>Compiler - Fehlermeldung:</p>
<pre><code>debug.cpp: In Funktion »int main()«:
debug.cpp:14:9: Fehler: keine Übereinstimmung für »operator=« in »Text = &quot;this is my text!&quot;«
debug.cpp:14:9: Anmerkung: Kandidat ist:
debug.cpp:4:7: Anmerkung: String&amp; String::operator=(const String&amp;)
debug.cpp:4:7: Anmerkung:   keine bekannte Umwandlung für Argument 1 von »const char [17]« nach »const String&amp;«
</code></pre>
<p>In meinen Vorstellungen müsste der Zuweisungsoperator doch zu erreichen sein? Was mache ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/304936/std-string-vererbung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 27 Jun 2026 13:44:25 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/304936.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 17 Jun 2012 14:11:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to std::string Vererbung on Sun, 17 Jun 2012 14:11:31 GMT]]></title><description><![CDATA[<p>Vererbung: String von std::string</p>
<pre><code class="language-cpp">#include &lt;string&gt;

class String : public std::string
{

};

using std::cout;

int main(void)
{
	String Text; // Text(&quot;This&quot;); funktioniert auch nicht
	Text = &quot;this is my text!&quot;;
	return 0;
}
</code></pre>
<p>Compiler - Fehlermeldung:</p>
<pre><code>debug.cpp: In Funktion »int main()«:
debug.cpp:14:9: Fehler: keine Übereinstimmung für »operator=« in »Text = &quot;this is my text!&quot;«
debug.cpp:14:9: Anmerkung: Kandidat ist:
debug.cpp:4:7: Anmerkung: String&amp; String::operator=(const String&amp;)
debug.cpp:4:7: Anmerkung:   keine bekannte Umwandlung für Argument 1 von »const char [17]« nach »const String&amp;«
</code></pre>
<p>In meinen Vorstellungen müsste der Zuweisungsoperator doch zu erreichen sein? Was mache ich falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224184</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224184</guid><dc:creator><![CDATA[RussianTux]]></dc:creator><pubDate>Sun, 17 Jun 2012 14:11:31 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Sun, 17 Jun 2012 14:17:24 GMT]]></title><description><![CDATA[<p>Es gibt in einer leeren Klasse (bereitgestellt durch den Compiler):<br />
* Default-Konstruktor<br />
* Kopier-Konstruktor<br />
* operator=<br />
* Destruktor</p>
<p>Jetzt überleg mal ganz scharf:<br />
* Gibt es einen String::operator=(char const*)<br />
* Gibt es einen String::String(char const*)</p>
<p>Desweiteren ist std::string nicht zum Ableiten gedacht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224188</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224188</guid><dc:creator><![CDATA[arghonaut]]></dc:creator><pubDate>Sun, 17 Jun 2012 14:17:24 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Sun, 17 Jun 2012 15:41:12 GMT]]></title><description><![CDATA[<p>arghonaut schrieb:</p>
<blockquote>
<p>Desweiteren ist std::string nicht zum Ableiten gedacht.</p>
</blockquote>
<p>Dann ist der weitere Aufwand es gar nicht Wert, danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224214</guid><dc:creator><![CDATA[RussianTux]]></dc:creator><pubDate>Sun, 17 Jun 2012 15:41:12 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Mon, 18 Jun 2012 18:51:29 GMT]]></title><description><![CDATA[<p>Die Frage ist was du damit erreichen willst.<br />
Statt std::string abzuleiten könntest du auch eine &quot;Wrapperklasse&quot; machen die einen string verwaltet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224714</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224714</guid><dc:creator><![CDATA[DarkShadow44]]></dc:creator><pubDate>Mon, 18 Jun 2012 18:51:29 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Mon, 18 Jun 2012 19:26:18 GMT]]></title><description><![CDATA[<p>DarkShadow44 schrieb:</p>
<blockquote>
<p>Die Frage ist was du damit erreichen willst.<br />
Statt std::string abzuleiten könntest du auch eine &quot;Wrapperklasse&quot; machen die einen string verwaltet.</p>
</blockquote>
<p>Wäre natürlich auch möglich, ist sogar keine so schlechte Idee</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224747</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224747</guid><dc:creator><![CDATA[RussianTux]]></dc:creator><pubDate>Mon, 18 Jun 2012 19:26:18 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Tue, 19 Jun 2012 09:16:32 GMT]]></title><description><![CDATA[<p>RussianTux schrieb:</p>
<blockquote>
<p>Wäre natürlich auch möglich, ist sogar keine so schlechte Idee</p>
</blockquote>
<p>Wenn es möglich ist, ist es nie eine schlechte Idee, eine Aggregation einer Vererbung vorzuziehen. Das reduziert die Kopplung, davon abgesehen willst du (hoffentlich) nicht das komplette unsagbar überladene std::string Interface mit dir rumschleppen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224908</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224908</guid><dc:creator><![CDATA[pumuckl]]></dc:creator><pubDate>Tue, 19 Jun 2012 09:16:32 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Tue, 19 Jun 2012 09:22:39 GMT]]></title><description><![CDATA[<p>Wieso kannst du nicht einfach std::string verwenden und fertig?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224912</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Tue, 19 Jun 2012 09:22:39 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Tue, 19 Jun 2012 10:40:21 GMT]]></title><description><![CDATA[<p>RussianTux schrieb:</p>
<blockquote>
<p>Wäre natürlich auch möglich, ist sogar keine so schlechte Idee</p>
</blockquote>
<p>Eine noch tollere Idee ist, deine Funktionalität einfach als freie Funktion hinzuzufügen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2224942</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2224942</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Tue, 19 Jun 2012 10:40:21 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Fri, 22 Jun 2012 22:43:05 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Wieso kannst du nicht einfach std::string verwenden und fertig?</p>
</blockquote>
<p>Weil es die Funktionalität nicht bietet, und nein, Boost brauche ich nicht!</p>
<p>Michael E. schrieb:</p>
<blockquote>
<p>RussianTux schrieb:</p>
<blockquote>
<p>Wäre natürlich auch möglich, ist sogar keine so schlechte Idee</p>
</blockquote>
<p>Eine noch tollere Idee ist, deine Funktionalität einfach als freie Funktion hinzuzufügen.</p>
</blockquote>
<p>Klar, sieht nur einbischen &quot;nicht OOP-mäßig&quot; aus, aber ist natürlich ne Lösung, ne Wrapper-Klasse wäre hier ideal, würde wie ein stinknormaler std::string aussehen und trotzdem alle Methoden aufem Interface anbieten</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2226358</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2226358</guid><dc:creator><![CDATA[RussianTux]]></dc:creator><pubDate>Fri, 22 Jun 2012 22:43:05 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Fri, 22 Jun 2012 22:53:24 GMT]]></title><description><![CDATA[<p>RussianTux schrieb:</p>
<blockquote>
<p>dot schrieb:</p>
<blockquote>
<p>Wieso kannst du nicht einfach std::string verwenden und fertig?</p>
</blockquote>
<p>Weil es die Funktionalität nicht bietet, und nein, Boost brauche ich nicht!</p>
</blockquote>
<p>Und um was für Funktionalität geht es da genau?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2226360</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2226360</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Fri, 22 Jun 2012 22:53:24 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Fri, 22 Jun 2012 23:36:41 GMT]]></title><description><![CDATA[<p>RussianTux schrieb:</p>
<blockquote>
<p>Klar, sieht nur einbischen &quot;nicht OOP-mäßig&quot; aus</p>
</blockquote>
<p>OOP hat rein gar nichts damit zu tun, ob man <code>objekt.funktion()</code> oder <code>funktion(objekt)</code> schreibt. Es ist im Gegenteil sogar die sauberste Lösung. Siehe z.B. <a href="http://www.drdobbs.com/184401197" rel="nofollow">http://www.drdobbs.com/184401197</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2226361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2226361</guid><dc:creator><![CDATA[Michael E.]]></dc:creator><pubDate>Fri, 22 Jun 2012 23:36:41 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Sat, 23 Jun 2012 01:00:27 GMT]]></title><description><![CDATA[<p>RussianTux schrieb:</p>
<blockquote>
<p>Klar, sieht nur einbischen &quot;nicht OOP-mäßig&quot; aus, aber ist natürlich ne Lösung, ne Wrapper-Klasse wäre hier ideal, würde wie ein stinknormaler std::string aussehen und trotzdem alle Methoden aufem Interface anbieten</p>
</blockquote>
<p>Ohne weitere Details zu kennen behaupte ich mal: nein, wäre nicht ideal, wäre einfach nur doof.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2226363</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2226363</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 23 Jun 2012 01:00:27 GMT</pubDate></item><item><title><![CDATA[Reply to std::string Vererbung on Sat, 23 Jun 2012 03:40:43 GMT]]></title><description><![CDATA[<p>einfach mal nen besseren string suchen, als den std</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2226365</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2226365</guid><dc:creator><![CDATA[oder]]></dc:creator><pubDate>Sat, 23 Jun 2012 03:40:43 GMT</pubDate></item></channel></rss>