Wednesday, February 20, 2008

 

Function overloading in C ++

The Function overloading is the practice of declaring the similar function with different signatures. Here, same function name will be used with different number of parameters and parameters of different type. However, overloading of functions with different return types is not allowed.

Some times when these overloaded functions are called, they may cause ambiguity errors. This is because the compiler may not be capable to decide what signature function should be called. If the data is type cast correctly, then these errors will be resolved simply. Normally, function overloading is used wherever a different type of data is to be dealt with. For instance this can be used for a function which converts Fahrenheit to Celsius and vice versa. One of the functions can deal with the integer data, other can deal float for accuracy etc.


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?