function overloadin or template functions which is better

Jul 29, 2013 at 12:57pm
which is better function overloading or template functions..?pls help..
Jul 29, 2013 at 1:06pm
if one was "better" than the other, the other one would be depreciated or never used. I do not know enough about the topic so i will just post the link to what i found.
http://stackoverflow.com/questions/12331655/function-overloading-vs-function-templates-c
Last edited on Jul 29, 2013 at 1:07pm
Jul 29, 2013 at 2:20pm
it was an interview question ...even i was not sure i just told them templates are better because it is new addtion to C++ ...i went through the link most of them say templates cannot take varying no of arg but tamplates can take varying no of agr
ex:
template <class type1, class type2>
type1 exp(type1 a, type2 b) {
return (b <= 0) ? 1 : a * exp(a, b - 1);
}

Topic archived. No new replies allowed.