Hi all,
I have a few points about function template that I need to clear up. So i have this array in main.
And I want to pass that one into a function template.Code:
double *array;
If i use the version 1 to declare the template, sort(array,length). that would make A a reference to double *, and Type=double *.Code:// version 1
template<class Type>
void sort(Type & A, int length)
//version 2
template<class Type>
void sort(Type * A, int length)
If i use version 2 , then A is a pointer to type double, and Type = double.
I tested out both template, and they both worked. But I want to ask you guys's opnions of which version is a better coding practice? or are they the same as long as I use Type consistently in the function body?
One more point that I am kind of confused is that if I use an explicit specialization for the function template, wouldn't it be the same as using a nontemplate function?