Skip to main content

What is difference between function overloading and template? tccicomputercoaching.com

Page 1

What is difference between function overloading and template? tccicomputercoaching.com Both function overloading and templates are examples of polymorphism. Function overloading is used when multiple functions do similar operations; templates are used when multiple functions do identical operations. Templates provide an advantage when you want to perform the same action on types that can be different.

Function Overloading works on different type’s no. of arguments. Syntax: 1. template: T sum(T a, T b) {

T c; c=a+b; return c;

} 2. Function Overloading: void sum(int a, int b) { ans =a+b;


Turn static files into dynamic content formats.

Create a flipbook