If funciton overloading and templates serve more the less the same purpose then which one should we go for templates or function overloading and what are the corresponding benefits.
If funciton overloading and templates serve more the less the same purpose then which
Share
With overloaded functions, you have to explicitly write out each overload:
This is tedious, but can be beneficial if the function body needs to be different based on the type.
Templates are nice when the same source code can be used for any type. You specify the pattern, and the compiler generates the expansions as needed: