1 2 3

*

When we define a function template at least oneof the parameters to the function mustbe of the class type, otherwise the compiler won't know which version of the function to generate. All it has to go on are the types of the function parameters
For example, the following declaration is incorrect

*

template < class T >
T& compute(
int number)
{
// this template will not work because.
// one of the
parametersMUST be of type T
...
};

*

You need to be careful about the interaction between template functions and overloading, since both of these mechanisms appear to be doing similar things. In the case of swap, the programmer could have produced a special purpose version of the swap procedure for character strings, one which understood about pointers to characters. To get this version of the swap procedure, and not the generated one, the parameters must match.

*

*The rules for template procedures and overloading are: 1. Exact match on a non-template function
2. Exact match using a template function

3. Ordinary parameter resolution on a non-template function