Multiple Parameters and Return Values from Generic Functions




This video tutorial explains how to pass multiple parameters to a generic or template function and also how to return values from a generic function.
You are gonna learn how to define a generic or template function which is gonna take multiple parameters, how to return values from a generic function using return keyword in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;
template <typename T> void display(T , T );
template <class T> T maxi(T x, T y);
int main()
{
cout << maxi(20,30)<<endl;
cout << maxi(20.256,3.897)<<endl;
display(20,30);
display("anil","anjali");
display(12.36,56.78);
}

template <typename T> void display(T x, T y){
cout << x << " and " << y << endl;
}

template <class T> T maxi(T x, T y){
return (x >= y) ? x : y;
}