| Previous Slide | Template Functions | Next Slide |
|
A better approach would be to write a template function. We
can write the code once and use it with different types of things.
The definition of a template function depends on an underlying data type. For example:
template <class Type>
Type maximum(Type a, Type b)
{
if (a > b)
return a;
else
return b;
}
The first line is the template prefix, which tells the
compiler that |