Define template function for class type : Template Overload « Generic « C++






Define template function for class type

Define template function for class type

#include <iostream>
using namespace std;

template <class type1, class type2>
void myFunction(type1 x, type2 y)
{
  cout << x << ' ' << y << '\n';
}

int main()
{
  myFunction(10, "hi");

  myFunction(0.23, 10L);

  return 0;
}

           
       








Related examples in the same category

1.Overload a function template declaration.Overload a function template declaration.
2.A generic version of myabs().A generic version of myabs().