Thanks, Zach. Your comments are perfectly understandable, but give rise to another question.
Given that a function template's nontype parameters are required to be constant values that are known at compile time, why would a programmer ever use that format?
Using my code as an example, is there ever a good reason to do this:
Code:
template<class Type, int s>
Array<Type, s>::Array(){
a = new Type[size = s];
}
...
};
int main(){
const int size=10;
...
Array<char,size> a1;
...
}
rather than this
Code:
template<class Type>
Array<Type>::Array(int s=10){
a = new Type[size = s];
}
...
};
int main(){
const int csize=5;
int vsize;
...
cout << "Enter array size: " << endl;
cin >> vsize;
Array<char> ca(csize); // any of these can be used to make an array
Array<string> sa; // " " "
Array<int> ia(vsize); // " " "
...
}
since the latter version allows for compile-time instantiation using a constant OR a default parameter OR run-time instantiation?
By the way, I love your signature line.