consider the following functions that returns the absolute value of an argument .
int abs(int i);
long labs(long i);
double fabs(double d);
All the above function performs same job, so it is improper to have three different function names c++ allows function overloading wherein the different programmer can create three different functions with the same name but different types of argument types of arguments as shown below
int abs(int i);
long abs(long i);
double abs(double d);
with function overoading we are relieved from the remembering different function names just because their arguments are different

0 comments:
Post a Comment