What is the overload of the method?
Overloading the
method is a function in most object -oriented programming languages in which two or more methods share the same name but have different parameters. Specifically, the number, data type and/or parameter order differ. When the code is compiled, the correct method will be selected automatically on the basis of what it is called. Methods are also known as functions in some programming languages, so overloading the method is sometimes referred to as overloading the function.
A simple example of overloading the method would be a method that calculates the square area. Can be defined as Getrearea (square). This method could be overloaded to calculate the circle area by adding the Getarea method (Circle C).
The primary requirement for overloading the method is that the methods share the same name. Their signatures of the method - the name of the method, the number of parameters and the types of parameter data - should otherwise be unique. In this way, thkompillator E can determine which method to do.
ConstrUktory, methods used to instance objects are often overloaded. This is done to initialize the object with values without defining. For example, an employee building with two fields (name and date of birth or time) may have the following constructors: employee (), employee (name) and employee (name, times). The first constructor creates an employee building with an empty name and poly times. The second sets the name field, but leaves the field empty and the third defines both the name and the field of the times.
Themethod is most commonly done so that more than one method logically appears as the only method. In the example of Getarea (), while there are physically two methods, the caller is presented with the only logical method of Getarea (). In this way, Getarea () can be expanded to work on other shapes - triangles, trapezes, and so on - and yet logically presents itself as the only method.
methods are also overloaded to maintain backward compatibility. The method that performs a comprehensive calculation could be provided a new requirement to optionally perform the same calculation with a slight change. A new parameter is added to the method to determine how to make a calculation - an old way or a new way.
To avoid having to find all the cases in which the method is called and add a new parameter, the method can be overloaded. The new method will have an old signature and will be called an existing code. It will not contain logic itself and simply calls a modified method and gives the default "old way" for a new parameter. The new code calls the modified method and hand over the new parameter with the appropriate value, the old or the new way.
The overload method is a type of polymorphism in which the same logical method can be used in practice in practice. The overload of the overload is not the same as the predominant method. The output of the method is the place where the definition of the method in the parent class will change children's classesou. In this case, both methods will have the same signature.