C++ examples for template:template function
Using int, char and float to test minimum template function
#include <iostream> // detemine the smallest of two arguments template <typename T> T minimum(T num1, T num2) {/*from w ww . ja va 2s .c om*/ return (num1 < num2) ? num1 : num2; } int main(int argc, const char *argv[]) { // int std::cout << "minimum(91,78): " << minimum(91, 78) << std::endl; // char std::cout << "minimum(x, G): " << minimum('x', 'G') << std::endl; // float std::cout << "minimum(61.25, 68.5): " << minimum(61.25, 68.5) << std::endl; return 0; }