Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

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

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;

}

void sum(int a , int b, int c)

{

ans=a+b+c;

}

To learn more concepts of Programming Languages at TCCI.

Visit us @ http://tccicomputercoaching.com/

Get Admission at TCCI.

Call us @ 9825618292

 

Leave a comment