Explicitly Overloading Generic Functions with Normal Functions






This video tutorial explains how to overload a generic function explicitly with a normal function c++ programming.
You are gonna learn what is meant by overloading a generic function explicitly and what is explicit specialization, what happens when we overload the generic function explicitly, what is the new syntax of specifying the explicit overloading of a generic function in detail with example.

source code for this tutorial

#include <iostream>

using namespace std;
template <typename T>void whatYouGot(T x);
template <>void whatYouGot<int>(int x);

int main()
{

    whatYouGot(23.456);
    whatYouGot(22);
    whatYouGot("anil shetty");
    return 0;
}

template <typename T>void whatYouGot(T x){

cout << "inside whatyougot generic function"<<endl;
cout << "i got x = "<<x<<endl;
}

template <>void whatYouGot<int>(int x){

cout << "inside whatyougot normal function"<<endl;
cout << "i got x = "<<x<<endl;
}

 
Back To Top