// The function template can be used to create a function with common functions to support multiple different parameters, further simplifying the function body design of the overloaded function. // Declaration method: // template <typename identifier> # include <iostream. h> template <typename T> t abs (t x) {return x <0? -X: X;} int main (void) {int n =-5; double D =-5.5; cout <ABS (n) <Endl; cout <ABS (d) <Endl; return 0 ;}// running result: // 5 // 5.5 // analysis: the type of the compiler's real parameters from ABS, type parameters of the function template. // For example, for calling the expression ABS (N), because the real parameter n is of the int type, the type parameter T in the export template is of the int type. // When the meaning of the type parameter is determined, the compiler generates a function: // int ABS (int x) // {// return x <0? -X: X ;//}