If several functions which use the same template are needed, is there a way to declare and implement them without declaring the template each time?
template <typename T>
T mymax (T a, T b);
template <typename T>
T mymin (T a, T b);
template <typename T>
T myfoo (T a, T b);
/********************************************/
template <typename T>
T mymax (T a, T b) {
return (a > b ? a : b);
}
template <typename T>
T mymin (T a, T b) {
return (a < b ? a : b);
}
template <typename T>
T myfoo (T a, T b) {
return max(a,b)+min(a,b);
}
Is there a way to write the line template <typename T>
just one time for a block of code? Something that will look like:
template <typename T> {
T mymax (T a, T b);
T mymin (T a, T b);
T myfoo (T a, T b);
}
(this code isn't legal syntax and doesn't compile)