A Function with Two Generic Types : generic parameters « Function « C++






A Function with Two Generic Types

   
#include <iostream>
using namespace std;
   
template <class type1, class type2>
void myfunc(type1 x, type2 y)
{
  cout << x << ' ' << y << '\n';
}
   
int main()
{
  myfunc(10, "I like C++");
   
  myfunc(98.6, 19L);
   
  return 0;
}
  
    
    
  








Related examples in the same category

1.Cast generic parameters
2.template for value output
3.Generic Function Restrictions
4.Applying Generic Functions: A Generic Bubble Sort
5.Generic function template