How would I re-write the GetMin function
How would I re-write the GetMin function so that it can return and take as parameters any datatype (not just int)
1 2 3 4 5 6
|
int GetMin (in a, int b) {
if(a<b) return a;
else return b;
}
|
By making it a template function.
1 2
|
template <typename T>
T GetMin( T a, T b ) { return a < b ? a : b; }
|
Topic archived. No new replies allowed.