<?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[static const]]></title><description><![CDATA[<p>hey</p>
<p>bei tmp ist es ja gang und gebe folgendes zu schreiben:</p>
<pre><code>template&lt;typename T&gt;
struct SomeTmpStuff
{
    static const bool Value = true;
};
</code></pre>
<p>aber wenn ich statische datenelemente mache teilweise, dann muss ich diese noch ausserhalb der klasse definieren. etwa so:</p>
<pre><code>struct Class
{
    static const std::string Test = &quot;hello!&quot;;
};
const std::string Class::Test;
</code></pre>
<p>also kann mir jemand erklären, wann genau man es alleine innerhalb der klasse belassen kann und wann man es ausserhalb nochmals hinschreiben muss?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321929/static-const</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Jul 2026 20:29:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321929.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 29 Nov 2013 09:49:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 09:49:21 GMT]]></title><description><![CDATA[<p>hey</p>
<p>bei tmp ist es ja gang und gebe folgendes zu schreiben:</p>
<pre><code>template&lt;typename T&gt;
struct SomeTmpStuff
{
    static const bool Value = true;
};
</code></pre>
<p>aber wenn ich statische datenelemente mache teilweise, dann muss ich diese noch ausserhalb der klasse definieren. etwa so:</p>
<pre><code>struct Class
{
    static const std::string Test = &quot;hello!&quot;;
};
const std::string Class::Test;
</code></pre>
<p>also kann mir jemand erklären, wann genau man es alleine innerhalb der klasse belassen kann und wann man es ausserhalb nochmals hinschreiben muss?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368843</guid><dc:creator><![CDATA[erlichter]]></dc:creator><pubDate>Fri, 29 Nov 2013 09:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 09:54:49 GMT]]></title><description><![CDATA[<p>Das ist nur für integrale Datentypen möglich und auch dann nur, wenn man niemals die Adresse von ihnen benötigt.<br />
Das erklärt auch gleich, warum es für nicht-integrale Typen nicht möglich ist: Klassen brauchen den this-Zeiger, also eine Instanz. Nun würde also die Instanz in jeder Übersetzungseinheit angelegt und würde die One-Definition-Rule verletzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368847</guid><dc:creator><![CDATA[decimad]]></dc:creator><pubDate>Fri, 29 Nov 2013 09:54:49 GMT</pubDate></item><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 09:56:28 GMT]]></title><description><![CDATA[<p>und wie ist das mit pod-datentypen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368849</guid><dc:creator><![CDATA[erlichter]]></dc:creator><pubDate>Fri, 29 Nov 2013 09:56:28 GMT</pubDate></item><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 09:58:34 GMT]]></title><description><![CDATA[<p>Du scheinst Dich doch auszukennen, wenn Du schon mit &quot;pod&quot; ankommst - ich verstehe nicht, warum Du Dich mit so einer Frage hierher wendest, statt kurz im Internet zu suchen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368851</guid><dc:creator><![CDATA[decimad]]></dc:creator><pubDate>Fri, 29 Nov 2013 09:58:34 GMT</pubDate></item><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 10:02:19 GMT]]></title><description><![CDATA[<p>Das geht bei ganzzahligen und Aufzählungstypen (mit der in-class Initialisierung) und solange du nicht ihre Adresse benutzt (ohne out-of-class Definition).</p>
<p>Siehe:<br />
<a href="http://www.stroustrup.com/bs_faq2.html#in-class" rel="nofollow">http://www.stroustrup.com/bs_faq2.html#in-class</a></p>
<p>edit: Viel zu langsam. Wieder zu viele Tabs gleichzeitig offen gehabt...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368852</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Fri, 29 Nov 2013 10:02:19 GMT</pubDate></item><item><title><![CDATA[Reply to static const on Fri, 29 Nov 2013 10:06:42 GMT]]></title><description><![CDATA[<p>danke für den link. jetzt ist es mir klarer.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2368854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2368854</guid><dc:creator><![CDATA[erlichter]]></dc:creator><pubDate>Fri, 29 Nov 2013 10:06:42 GMT</pubDate></item></channel></rss>