Simple template function to accept two parameters : Function Template « Function « C++






Simple template function to accept two parameters

Simple template function to accept two parameters
 
#include <iostream>
using namespace std;

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

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

  myFunction(0.23, 10L);

  return 0;
}


           
         
  








Related examples in the same category

1.A generic mode finding function.A generic mode finding function.
2.Function template: swap valuesFunction template: swap values
3.template function for find a valuetemplate function for find a value
4.Creating a custom algorithm based on templateCreating a custom algorithm based on template
5.find all template function
6.Using a Binary Function to Multiply Two Ranges
7.Making a Sequence of Random Numbers
8.write function object
9.Use a Function Object to Hold state
10.template function for bubble sort
11.template function for compacting the items
12.Template copy array function
13.function template for getting the max value
14.Overriding a template function.
15.Using Standard Parameters with Template Functions