title: Why is the const keyword is mandatory for defining template parameters?
body: <p>I just wanted to know why should i make the variables that i pass to the function templates has to be const?</p>
  
  <p>example:-</p>
  
  <pre><code>   #include &lt;iostream&gt;
     using std::cout;
     using std::endl;
  
     template&lt; typename T&gt;
     void printArray( T *array, int count )
     {
        for ( int i = 0; i &lt; count; i++ )
           cout &lt;&lt; array[ i ] &lt;&lt; " ";
        cout &lt;&lt; endl;
     }
  
     int main()
     {
       const int ACOUNT = 5; // size of array a
       const int BCOUNT = 7; // size of array b
       const int CCOUNT = 6; // size of array c
  
       int a[ ACOUNT ] = { 1, 2, 3, 4, 5 };
       double b[ BCOUNT ] = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 };
       char c[ CCOUNT ] = "HELLO"; // 6th position for null
  
       cout &lt;&lt; "Array a contains:" &lt;&lt; endl;
  
       // call integer function-template specialization
       printArray( a, ACOUNT );
  
       cout &lt;&lt; "Array b contains:" &lt;&lt; endl;
  
       // call double function-template specialization
       printArray( b, BCOUNT );
  
       cout &lt;&lt; "Array c contains:" &lt;&lt; endl;
  
       // call character function-template specialization
       printArray( c, CCOUNT );
       return 0;
     }
  </code></pre>
  
  <p>Here in main function:-
  I declare the variables </p>
  
  <pre><code> const int ACOUNT = 5; // size of array a
   const int BCOUNT = 7; // size of array b
   const int CCOUNT = 6; // size of array c
  </code></pre>
  
  <p>as <code>const</code>. If I don't declare them as const then I would get an error "Uninitialized array".</p>
  
  <p>Can anyone please let me know if that is the rule that the parameters sent to function templates has to be of const type?</p>