Generic function allows the type parameter to be deduced : Generic Function « Generics « Visual C++ .NET






Generic function allows the type parameter to be deduced

 

#include "stdafx.h"
using namespace System;

generic < typename T>
void GenericFunction(T t)
{
   Console::WriteLine(t);
}

int main()
{
   int i;

   GenericFunction<int>( 200 );


   GenericFunction( 400 );
}

   
  








Related examples in the same category

1.Generic function demo
2.Generic function and generic array
3.generic multiple constraints
4.generic return value
5.Specify the type parameter for generic function