Hi all:
I want to declare a set of tempalted functions not in a class, but to use it globally and generally. My code looks like:
template <class T>
void Minmax(const vector<T>&arr, T& minn, T& maxx){
T x = arr[0], y = arr[0];
for (unsigned int i=1; i < arr.size(); i++){
if (y < arr) y = arr;
if (arr < x) x = arr;
}
minn = x;
maxx = y;
}
And I want to use it as in this way:
vector<my_class> my_array;
my_class minn, maxx;
Minmax(my_array, minn, maxx);
But it didn't work. Could anyone help me with this please?
Thanks
[Edited by - Asuralm on February 15, 2008 8:06:06 AM]