<?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[&amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht]]></title><description><![CDATA[<p>Ich habe folgende Header-Datei:<br />
Constants.h</p>
<pre><code class="language-cpp">#ifndef CONSTANTS_H_
#define CONSTANTS_H_

class Constants {

	public:
	static const int numberOfStatisticObjects = 71; //71 Global + IPs

	static const int numberOfPoissonAttributes = 10; //2;
	static const int numberOfASNAttributes = 21; //3; //21 (20 + Rest)
	static const int number30MinIntervals = 48; //3; //48
	static const int numberOfDays = 7; //10; //7
	static const int scaleFactor = 30; &lt;----------- Ich beziehe mich hierauf
	static const int number10SecIntervals = 180; //2; //180

	static const int numberOfIterations = 1000; //2000
	static const int numberSkipIterations = 990; //1000

};

#endif /* CONSTANTS_H_ */
</code></pre>
<p>Dann in einer Klasse (die natürlich Constants einbindet) steht folgende Codezeile</p>
<pre><code class="language-cpp">lambda[j] = 1/((double) Constants::scaleFactor) * poissonAttributesGibbsMatrices[i][0][j] * poissonAttributesGibbsMatrices[i][current30MinIntervalIndex][j];
</code></pre>
<p>Soweit so gut. Das funktioniert auch wunderbar.</p>
<p>Jetzt habe ich die Constants.h aber mal ein wenig geändert und sie sieht jetzt folgendermaßen aus:</p>
<pre><code class="language-cpp">static const double scaleFactor = 30;
</code></pre>
<p>D.h. ich ersetze einfach int durch double und erhalte dann folgenden Fehler beim Kompilieren:</p>
<blockquote>
<p>g++ -lgsl -o DDoS DDoS.o StatisticsObject.o DataProcessor.o RandomNumberGenerator.o AutolartVector.o GibbsSampler.o ASN_Classifier.o DDoS_Main.o<br />
Undefined symbols:<br />
&quot;Constants::scaleFactor&quot;, referenced from:<br />
__ZN9Constants11scaleFactorE$non_lazy_ptr in StatisticsObject.o<br />
ld: symbol(s) not found<br />
collect2: ld returned 1 exit status<br />
make: *** [all] Error 1</p>
</blockquote>
<p>Wieso geht das nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/267981/quot-static-const-int-quot-geht-aber-quot-static-const-double-quot-nicht</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 06:12:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/267981.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 02 Jun 2010 10:01:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 10:01:54 GMT]]></title><description><![CDATA[<p>Ich habe folgende Header-Datei:<br />
Constants.h</p>
<pre><code class="language-cpp">#ifndef CONSTANTS_H_
#define CONSTANTS_H_

class Constants {

	public:
	static const int numberOfStatisticObjects = 71; //71 Global + IPs

	static const int numberOfPoissonAttributes = 10; //2;
	static const int numberOfASNAttributes = 21; //3; //21 (20 + Rest)
	static const int number30MinIntervals = 48; //3; //48
	static const int numberOfDays = 7; //10; //7
	static const int scaleFactor = 30; &lt;----------- Ich beziehe mich hierauf
	static const int number10SecIntervals = 180; //2; //180

	static const int numberOfIterations = 1000; //2000
	static const int numberSkipIterations = 990; //1000

};

#endif /* CONSTANTS_H_ */
</code></pre>
<p>Dann in einer Klasse (die natürlich Constants einbindet) steht folgende Codezeile</p>
<pre><code class="language-cpp">lambda[j] = 1/((double) Constants::scaleFactor) * poissonAttributesGibbsMatrices[i][0][j] * poissonAttributesGibbsMatrices[i][current30MinIntervalIndex][j];
</code></pre>
<p>Soweit so gut. Das funktioniert auch wunderbar.</p>
<p>Jetzt habe ich die Constants.h aber mal ein wenig geändert und sie sieht jetzt folgendermaßen aus:</p>
<pre><code class="language-cpp">static const double scaleFactor = 30;
</code></pre>
<p>D.h. ich ersetze einfach int durch double und erhalte dann folgenden Fehler beim Kompilieren:</p>
<blockquote>
<p>g++ -lgsl -o DDoS DDoS.o StatisticsObject.o DataProcessor.o RandomNumberGenerator.o AutolartVector.o GibbsSampler.o ASN_Classifier.o DDoS_Main.o<br />
Undefined symbols:<br />
&quot;Constants::scaleFactor&quot;, referenced from:<br />
__ZN9Constants11scaleFactorE$non_lazy_ptr in StatisticsObject.o<br />
ld: symbol(s) not found<br />
collect2: ld returned 1 exit status<br />
make: *** [all] Error 1</p>
</blockquote>
<p>Wieso geht das nicht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905802</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905802</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 02 Jun 2010 10:01:54 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 10:08:54 GMT]]></title><description><![CDATA[<p>Weil du es in der Source-Datei nicht ebenfalls geändert hast.</p>
<p>Außerdem: 30. anstelle von 30</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905803</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905803</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Wed, 02 Jun 2010 10:08:54 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 10:31:26 GMT]]></title><description><![CDATA[<p>Sorry, ich hatte das schon in 30.0 geändert und es kam/kommt derselbe Fehler. Daran leigt es nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905813</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905813</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 02 Jun 2010 10:31:26 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 10:41:28 GMT]]></title><description><![CDATA[<p>Was soll ich denn in welcher Source-File ändern?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905821</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905821</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 02 Jun 2010 10:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 11:00:58 GMT]]></title><description><![CDATA[<p>Eine Initialisierung von statischen Datenelementen einer Klasse ist nur integralen Typen vorbehalten. Warum schreibst Du es nicht so...</p>
<pre><code class="language-cpp">namespace constants {
  const int foo = 42;
  const double bar = 3.1415;
}
</code></pre>
<p>?</p>
<p>Warum Du hier eine Klasse missbrauchst, ist mir ein Rätsel.</p>
<p>kk</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905832</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 02 Jun 2010 11:00:58 GMT</pubDate></item><item><title><![CDATA[Reply to &amp;quot;static const int&amp;quot; geht aber &amp;quot;static const double&amp;quot; nicht on Wed, 02 Jun 2010 11:02:06 GMT]]></title><description><![CDATA[<p>krümelkacker schrieb:</p>
<blockquote>
<p>Eine Initialisierung von statischen Datenelementen...</p>
</blockquote>
<p>genauer: eine &quot;in-class Initialisierung&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1905833</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1905833</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Wed, 02 Jun 2010 11:02:06 GMT</pubDate></item></channel></rss>