title: Why can't I use float value as a template parameter?
body: <p>When I try to use <code>float</code> as a template parameter, the compiler cries for this code, while <code>int</code> works fine.</p>
  
  <p>Is it because I cannot use <code>float</code> as a template parameter?</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  template &lt;class T, T defaultValue&gt;
  class GenericClass
  {
  private:
      T value;
  public:
      GenericClass()
      {
          value = defaultValue;
      }
  
      T returnVal()
      {
          return value;
      }
  }; 
  
  
  int main()
  {
      GenericClass &lt;int, 10&gt; gcInteger;
      GenericClass &lt; float, 4.6f&gt; gcFlaot;
  
      cout &lt;&lt; "\n sum of integer is "&lt;&lt;gcInteger.returnVal();
      cout &lt;&lt; "\n sum of float is "&lt;&lt;gcFlaot.returnVal();
  
      return 0;       
  }
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <pre class="lang-none prettyprint-override"><code>main.cpp: In function `int main()':
  main.cpp:25: error: `float' is not a valid type for a template constant parameter
  main.cpp:25: error: invalid type in declaration before ';' token
  
  main.cpp:28: error: request for member `returnVal' in `gcFlaot',
                      which is of non-class type `int'
  </code></pre>
  
  <p>I am reading <em>"Data Structures for Game Programmers"</em> by Ron Penton, the author passes a <code>float</code>, but when I try it it doesn't seem to compile.</p>