template for value output : generic parameters « Function « C++






template for value output

  
#include <iostream>
using namespace std;
template <class T1, class T2> void sample(T1 x, T2 y);

int main(void)
{
   sample(10, "hi");
   sample(0.23, 10L);
   sample("Jamsa's", "C/C++");
}

template <class T1, class T2> void sample(T1 x, T2 y)
{
   cout << x << " " << y << endl;
}
  
    
  








Related examples in the same category

1.Cast generic parameters
2.A Function with Two Generic Types
3.Generic Function Restrictions
4.Applying Generic Functions: A Generic Bubble Sort
5.Generic function template