Submitted by: Raj
The function template has only one definition for various types.
But its not the case for the function over loading.
For eg.,
#include "stdafx.h"
#include "stdio.h"
#include "windows.h"
#include<iostream.h>
#include "test.h"
template < class T>
T add(T a, T b)
{
T c;
c= a+b;
return c;
}
int main()
{
cout << add<int>(1,2)<<endl;
cout << add<float>(1.0,2.0)endl;
return 0;
}
But for the function overloading there has to be different datatypes defined for each functions.
Above answer was rated as good by the following members:
rish_LP, YaelG, yzesong, j_l_larson