C++ Programming Code Examples C++ > Beginners Lab Assignments Code Examples Simple Function Template Program to Get Maximum Number Simple Function Template Program to Get Maximum Number Generic Programming Templates are a feature of the C++ programming language that allows functions and classes to operate with generic types Function Template Definition A function template behaves same as normal function except that the template works with different data types. // Header Files #include<iostream> #include<stdio.h> #include<conio.h> using namespace std; // Template Declaration template<class T> // Template Function T getMaximun(T x, T y) { if (x > y) return x; else return y; } int main() { int a, b, i; float c, d, j; cout << "Function Template Programs : Get Maximum Number \n"; cout << "Enter A,B values(integer):"; cin >> a>>b; i = getMaximun<int>(a, b); cout << "Result Max Int : " << i; cout << "\n\nEnter C,D values(float):"; cin >> c>>d; j = getMaximun<float>(c, d); cout << "Result Max Float : " << j; getch(); return 0; }