Function Template : template « Function « Visual C++ .NET






Function Template

 

#include "stdafx.h"
using namespace System;

template <class T>
T min ( T a, T b){
    return (a < b) ? a : b;
}

void main() {
    int    a = 5;
    int    b = 6;
    double c = 5.1;

    Console::WriteLine("The min of {0} and {1} is {2}", a, b, min(a,b));
    Console::WriteLine("The min of {0} and {1} is {2}", a, c, min<double>(a,c));

}

   
  








Related examples in the same category