+ 2

In which cases should you use function template and function overloading

15th Sep 2019, 8:14 PM
Sarfo Agyemang
Sarfo Agyemang - avatar
3 Answers
+ 1
You would use function overloading when you cant be sure of the arguments that may be passed to that function, so you would have one function copied multiples times with the same signature but with diffrenet parameters to cover all possible inputs.
15th Sep 2019, 8:22 PM
D_Stark
D_Stark - avatar
+ 1
if we need to perform identical operations on two or more types of data, we use function overloading to create two function with the required function declaration. However, a better approach would be to use function templates
7th Oct 2019, 5:24 PM
Priya Trikoti
Priya Trikoti - avatar