| 1. |
What is function overloading? Explain the need for overloading. |
|
Answer» The overloading helps to apply polymorphism because Function overloading means two or more functions having same name but different types of arguments or different number of arguments. Whereas polymorphism refers to “one name having many forms of an object behavior depending on situations. Function overloading is normally used when several functions of the same name perform identical tasks on different data types. The overloading function helps to reduce the use of different names for many functions. The developer of the program can use one function name to give function call to one in many functions and C++ select the appropriate function by checking the number of parameter and type of parameters. This reduces the selecting a function block to give a function call by the user. It is easier to understand the flow of information that helps in faster debug. Easy program maintenance. There can be a common interface between programs and real-world objects. |
|