Function Templates - Example 10-3 - A function template that always returns a double

// File: ex10-3.cpp

#include <iostream>
using namespace std;

template <typename Z> double half(Z n)
{
	return (double) n/2.;
}

int main(void)
{
	cout << half(3) << endl;
	cout << half(4.55) << endl;
	cout << half(static_cast<short>(2)) << endl;
	cout << half(static_cast<long>(19)) << endl;
	cout << half(1/2) << endl;
	cout << half('x') << endl;
	return 0;
}
/***** Output *****
1.5
2.275
1
9.5
0
60
*********************/