Overloading Generic Function Template




This video tutorial explains how to overload generic function templates in c++ programming.
You are gonna learn how to define a generic functions and overload their templates, how to use the overloaded template functions or generic functions, how to pass  values to a overloaded template function function in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;

template <typename T> void whatYouGot(T x);
template <typename T1,typename T2> void whatYouGot(T1 x, T2 y);

int main()
{
    whatYouGot(55);
    whatYouGot("anil");
    whatYouGot(55.68);
    whatYouGot(55,33.59);
    whatYouGot("anil","anjali");

    return 0;
}


template <typename T> void whatYouGot(T x){
cout << "generic function with one parameter "<<endl;
cout << "i got x = "<<x<<endl;
}

template <typename T1,typename T2> void whatYouGot(T1 x, T2 y){
cout << "generic function with two parameter "<<endl;
cout << "i got x = "<<x<<endl;
cout << "i got y = "<<y<<endl;
}

 
Back To Top