// The C ++ template is parameterized.ProgramDesign method, which is a completely common method to design functions or classes
// You do not need to specify the types of each object to be used in advance. The types of these template calculation objects are not actual.
// Data type, but a parameterized type (also known as a type parameter ).
// A class with a type parameter is called a class template.
// A function with a type parameter is called a function template.
// The type parameter of the template is determined by the type of the actual parameter called by the compiler.
// Truly executableCodeThis process is called Instantiation.
// A function template is called a template function after the type is instantiated.
// A class template is called a template class after the type is instantiated.
# Include <iostream>
Using namespace STD;
// The overload function usually performs similar operations based on different data types.
// They are all the same, so it is more concise and convenient to use the function template to complete this task.
Template <typename T>
Void Exchange (T & x, t & Y)
{
TTemp;
Temp = X;
X = y;
Y = temp;
}
Void main ()
{
IntI = 7, j = 8;
Exchange (I, j );
Cout <"I =" <I <"\ TJ =" <j <Endl;
Double A = 3.14, B = 6.2;
Exchange (A, B );
Cout <"A =" <A <"\ TB =" <B <Endl;
Char X = 'x', y = 'y ';
Exchange (x, y );
Cout <"x =" <x <"\ ty =" <Y <Endl;
}