I have been experimenting with a simple array class template two ways: one using only a class parameter, and the other using a function-style parameter. Everything else is the same.
The version that uses only the class parameter tests out fine. In my test driver I was able to use a variable "arraySize", prompt the user for a value for that variable, and use it to allocate arrays with no errors.
But in the version that uses a function-style parameter (using "arraySize" as the function-style template parameter), it would not compile until I changed the declaration of arraySize to a constant, for example:
const int arraySize = 5;
Of course, I can no longer prompt the user to designate the size.
Is this normal? Is this a limitation of function-style parameters for templates? Or did I do something else wrong?



LinkBack URL
About LinkBacks


