A function template can be override for a particular data type.  see below example

#include<iostream>
using namespace std;

template < typename T, typename S > void
add (T a, S b)
{
  cout << "In template version ";
  cout << (a + b);
  cout << endl;
}

void
add (float a, float b)
{
  cout << "in Float version ";
  cout << (a + b);
  cout << endl;
}

int
main ()
{

  int a = 1;
  int b = 2;
  float c = 2.1;
  float d = 3.2;

  // call function add
  add (a, b);            // this will call template version of add
  add (c, d);            // this will oerride the template function
  // add and call non template function add
  return 0;
}

The output :

In template version 3
in Float version 5.3



Related Contents to follow