function templates
Some algorithms are independent of type, so you can define a function's parameter type as a special "parameter" so that you get a "function template"
How to define a function template:
Template<typename t> return type function name (function parameter);
such as: Template<typename t> t sum (t A, T B) {return a + B;}
The function template calls, because the compiler can automatically deduce the actual parameters of the type, so formally call a function template and
There is no difference between ordinary functions, such as:
int main ()
{
int a = 3, b = 4;
cout << sum (A, b);
float f1=1.3, f2 = 9.1;
cout << sum (F1,F2);
}
Function template parameters can also be assigned default values, such as
Template<typename T0 = float,
TypeName T1,
TypeName T2 = float,
TypeName T3,
TypeName T4>
Tofunc (T1 v1,t2 v2, T3 v3, T4 v4) {...}
...
Func (n/a);
Func (' A ', ' B ', ' abc ');
C + + Programming Method 4: Function templates