   What is wrong with my template function?
Main.h #ifndef _Main_h#define _Main_htemplate<class dataType>class CArray{dataType * _array;int _size;public:   CArray(void): _size(20)   {    _array = new dataType[_size];   } CArray(int paramSize): _size(paramSize)   {    _array = new dataType[_size];   } ~CArray(void)   {    if( _array != NULL ) {    delete [] _array; }  _array = NULL;   } operator dataType*(void)   {    return _array;   } dataType & operator[](int element)   {    return _array[element];   } void resize(int newSize)   { if( _array != NULL ) {    delete [] _array; }  _array = NULL; _size = newSize; _array = new dataType[newSize];   } void insert(int element, dataType value)   {    for( int index = _size - 1; index > element; index-- ) {_array[index] = _array[index - 1]; }  _array[element] = value;   }   void clear(dataType zero)   {    for( int index = 0; index < _size; index++ ) {_array[index] = zero; }    }   int GetSize(void) const   {    return _size;   }   };#endifMain.cpp #include <iostream>#include <cstdlib>#include <time.h>#include "Main.h"   using std::cout;   using std::cin;   using std::endl; template<typename dataType, const int MAX, dataType value>   void Process(dataType*&); template<typename dataType, const int MAX>   void Process2(dataType*); int main(void){srand( (int)time(NULL) );CArray<int> array(9);Process<int, array.GetSize(), int(rand() % 10)>(array);cin.get();return EXIT_SUCCESS;}template<typename dataType, int MAX, dataType value>void Process( dataType *& pArray ){for( int index = 0; index < MAX; index++ ){   pArray[index] = value;}}template<typename dataType, const int MAX>void Process2( dataType * pArray ){for( int index = 0; index < MAX; index++ ){   cout << pArray[index] << endl;}}    --------"Do you believe in Ghost?" 
  Is this a compile time error or a runtime error? I''m not going to look through your code unless I have at least some idea what your problem is. ;  i could be wrong, (which i probably am, buuut)...isn' tthe syntax for declaring a template thus: template <class type>void F(type t){   t = t;}notice the "class" keyword...am i missing something? otherwise you haven't declared "typename" anywhere...------------------------------------------ [edited by - MrBeaner on February 7, 2004 12:52:27 AM];  Both typename and class are legit, unless your template parameter is itself a template.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor);  All template parameters must be compile-time constants... that means you cannot do: Process<int, array.GetSize(), int(rand() % 10)>(array);since "int(rand() % 10" is not a compile-time constant. ;  Its a compile error on the line Daniel just pointed out.What do you mean by compile-constant?   --------"Do you believe in Ghost?" ;quote:Original post by Fruny  Both typename and class are legit, unless your template parameter is itself a template.   “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”    — Brian W. Kernighan (C programming language co-inventor) What is the difference between the two? ;  MrBeaner: There is no difference.  [/matrix reference]  Seriously.  class and typename are interpreted the same way in template parameter lists. ;quote:Original post by MrBeaner   What is the difference between the two?   Within a template declaration, they are completely interchangeable.Only when you have something of the form template <template<typename T> class U> ... is the 'outer' class mandatory (because U really is a class).The typename keyword has other usages, all related to the need to disambiguates between members which are variables/functions... and members which are types:template <class Container> typename T::value_typefirst(Container c){   return *(c.begin());}   Without the typename keyword, your compiler would interpret T::value_type as a static member. typename precises that it really is a type. Since T is not yet known when you write the template, you have to specify which one is right.   [edited by - Fruny on February 8, 2004 1:51:09 AM];quote:Original post by Leiarchy9  Its a compile error on the line Daniel just pointed out.What do you mean by compile-constant?   --------"Do you believe in Ghost?"   A compile constant is a constant which value is known at compile-time...For example: int b;ExampleClass<2+4*3> a; //You can do this, since 2+4*3 is a constant that is known at compile-timeExampleClass<3*b> c; //This cause an error, since you don`t know at compile time what will be the value of "b" by the time this line is executed in runtime