+1 vote
in Class 12 by kratos

Write a short note on function overloading.

1 Answer

+5 votes
by kratos
 
Best answer

Function overloading means two or more functions having same name but different types of arguments or different numbers of arguments. Function overloading is also known as compile time polymorphism. Function overloading is normally used when several functions of the same name perform identical tasks on different data types.

Reasons for function overloading.

  1. The overloading function helps to reduce the use of different names for many functions.
  2. The developer of the program can use one function name to give function call to one in many functions. This reduces selecting a function block to give a function call by the user.
  3. It is easier to understand the flow of information that helps in faster debug.
  4. Easy program maintenance.

The restrictions on overloaded functions are

  • The parameters/arguments should differ in the number of arguments or if they have same number of argument then they should differ in the type of the arguments
  • The use of typedef keyword for naming functions is not treated as different type but is only a synonym for another type.

Declaration and Definition of overloaded functions:

...