Generic Functions with Multiple Generic Types
This video tutorial explains how to write a generic function which takes multiple generic type parameters in c++ programming.
You are gonna learn how to define a generic function to take multiple generic types of parameters, how to use the multiple generic types in a generic function, how to pass different types of values to a function in detail with example.
source code for this tutorial
#include <iostream>
using namespace std;
template <typename T1, typename T2 > void display(T1 x, T2 y);
int main()
{
display("anil",24);
display(24,65.89);
display(24,65);
display(24.36,65.89);
display("anil","anjali");
return 0;
}
template <typename T1, typename T2 > void display(T1 x, T2 y){
cout << x << " and "<<y<<endl;
}