Your syntax needs help. See the C++ FAQ Lite.
The difference between a regular class or function and a template class or function is just that you have template<typename Foo>
in front of it, and can use Foo as a generic type instead of a specific type like int, or string or somesuch.
So:
//print an array of ints
void printa( int a[], int len ) {
for (int i = 0; i < len; i++)
std::cout << a[ i ] << std::endl;
}
can be made to print any printable thing by turning it into a template function:
//print an array of any printable thing
template<typename PrintableThing>
void printa( PrintableThing a[], int len ) {
for (int i = 0; i < len; i++)
std::cout << a[ i ] << std::endl;
}
Now I can print arrays of strings, floats, etc...
Compare the difference between the two functions, read your textbook over again, and look at the C++ FAQ Lite page I gave you. Also, use the word "typename" instead of "class" in your template declarations.
Hope this helps.