Why can't I have a non-integral static const member in a class?
<p>I noticed C++ will not compile the following:</p>

<pre><code>class No_Good {
  static double const d = 1.0;
};
</code></pre>

<p>However it will happily allow a variation where the double is changed to an int, unsigned, or any integral type:</p>

<pre><code>class Happy_Times {
  static unsigned const u = 1;
};
</code></pre>

<p>My solution was to alter it to read:</p>

<pre><code>class Now_Good {
  static double d() { return 1.0; }
};
</code></pre>

<p>and figure that the compiler will be smart enough to inline where necessary... but it left me curious.</p>

<p>Why would the C++ designer(s) allow me to static const an int or unsigned, but not a double?</p>

<p>Edit: I am using visual studio 7.1 (.net 2003) on Windows XP.</p>

<p>Edit2:</p>

<p>Question has been answered, but for completion, the error I was seeing:</p>

<pre><code>error C2864: 'd' : only const static integral data members can be initialized inside a class or struct
</code></pre>
