Coupon Accepted Successfully!


Precautions With Function Overloading

Function overloading is a powerful feature of C++. But, this facility should not be overused. Otherwise it becomes an additional overhead in terms of readability and maintenance. Following precautions must be taken:

  1. Only those functions that basically do the same task, on different sets of data, should be overloaded. The overloading of function with identical name but for different purposes should be avoided.
  2. In function overloading, more than one function has to be actually defined and each of these occupy memory.
  3. Instead of function overloading, using default arguments may make more sense and fewer overheads.
  4. Declare function prototypes before main() and pass variables instead of passing constant directly. This will avoid ambiguity that frequently occurs while overloading functions.

Test Your Skills Now!
Take a Quiz now
Reviewer Name