<?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[Einfache Frage zu statischen Variablen&#x2F;Methoden]]></title><description><![CDATA[<p>Ich habe etwas in der Art:</p>
<pre><code class="language-cpp">// Header
class StatischTest
{
public:
  static bool doIt;
  static void yesWeCan();
}

bool StatischTest::doIt = true;
</code></pre>
<pre><code class="language-cpp">// CPPclass StatischTest

void StatischTest::yesWeCan()
{
  print &quot;NO WE CANT&quot;;
}
</code></pre>
<p>Ich erhalte undefined reference to StatischTest::doIt<br />
Warum ist das so, und vor allem: wie behebe ich es</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/288611/einfache-frage-zu-statischen-variablen-methoden</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 22:00:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/288611.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 19 Jun 2011 21:00:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Sun, 19 Jun 2011 21:00:28 GMT]]></title><description><![CDATA[<p>Ich habe etwas in der Art:</p>
<pre><code class="language-cpp">// Header
class StatischTest
{
public:
  static bool doIt;
  static void yesWeCan();
}

bool StatischTest::doIt = true;
</code></pre>
<pre><code class="language-cpp">// CPPclass StatischTest

void StatischTest::yesWeCan()
{
  print &quot;NO WE CANT&quot;;
}
</code></pre>
<p>Ich erhalte undefined reference to StatischTest::doIt<br />
Warum ist das so, und vor allem: wie behebe ich es</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080843</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Sun, 19 Jun 2011 21:00:28 GMT</pubDate></item><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Sun, 19 Jun 2011 21:03:12 GMT]]></title><description><![CDATA[<p>sorry das wichtigste ist:</p>
<p>in yesWeCan die Zeile:</p>
<pre><code class="language-cpp">if(StatischTest::doIt)
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2080845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080845</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Sun, 19 Jun 2011 21:03:12 GMT</pubDate></item><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Sun, 19 Jun 2011 21:06:21 GMT]]></title><description><![CDATA[<p>Eigentlich hätte ich bei der Konstellation einen anderen Fehler erwartet - du hast die Definition des statischen Members im Header und damit das Risiko einer Mehrfach-Definition.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080847</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080847</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Sun, 19 Jun 2011 21:06:21 GMT</pubDate></item><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Sun, 19 Jun 2011 21:24:27 GMT]]></title><description><![CDATA[<p>tz tz tz , das kommt davon wenn man MinimalBeispiele basteln will.</p>
<p>Nochmal:</p>
<pre><code class="language-cpp">//Header
class Test
{
private:

public:
    static Typ* variable;
    static bool isSetUp;

    static void init();
    static void release();
    static Typ* getVariable();
};
</code></pre>
<pre><code class="language-cpp">//CPPclass Test
Typ* Test::variable = 0;
bool Test::isSetUp = false;

void Test::init()
{
    if (!Test::isSetUp)
    {
        Test::variable = new VonTypAbgeleitet();
        Test::isSetUp = true;
    }

}

void Test::release()
{
    if (Test::isSetUp)
    {
        delete Test::variable ;
        Test::isSetUp = false;
    }
}
Typ* Test::getVariable()
{
  if (Test::isSetUp)
        return Test::variable;
  return 0;
}
</code></pre>
<p>In etwa, ein paar Sachen passen immer noch nicht aber es kommt hin</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080857</guid><dc:creator><![CDATA[shisha]]></dc:creator><pubDate>Sun, 19 Jun 2011 21:24:27 GMT</pubDate></item><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Sun, 19 Jun 2011 22:21:45 GMT]]></title><description><![CDATA[<p>Ich sehe hier auch nix was zu einer &quot;undefined reference&quot; führen würde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2080875</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2080875</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sun, 19 Jun 2011 22:21:45 GMT</pubDate></item><item><title><![CDATA[Reply to Einfache Frage zu statischen Variablen&#x2F;Methoden on Mon, 20 Jun 2011 10:47:52 GMT]]></title><description><![CDATA[<p>In der Code-Datei sollte ein Include für den dazugehörigen Header stehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2081002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2081002</guid><dc:creator><![CDATA[EOutOfResources]]></dc:creator><pubDate>Mon, 20 Jun 2011 10:47:52 GMT</pubDate></item></channel></rss>