When any program contains multiple functions, whose name is the same, but the parameters are different, they are known as overloaded. We use this technique to increase the readability of the program.
To overload the functions, we will use two methods. -
We usually will do the function overloading when we want to perform one operation, containing different numbers or types of arguments.
Function Overloading in C++
Function Overloading in C++ will be like as shown below:
The output of the above program will look like, as shown below:
Now we will take another example of the function overloading.
Now the output of the above program will look like as shown in the below screenshot:
Function Overloading in Erlang
In the system, the Overloading process regulates the use of the CPU. In the function overloading, the main application calls the request function before doing any job and executes the process when it returns the positive value; else, the job will not start.
Overload is the part of the sas1 application, and we can define all the configuration parameter here.
We will maintain the two sets of intensity; those are the total intensity and the accept intensity. Intensities can be measured through the configuration parameters, which are: MaxIntensity and the Weight value. Both the intensities will be measured according to the 1/second.
Total intensity can be calculated, as shown below:
The assumption is that the current call to request/0 is K(n), and the time of the previous call was K(n-1). The current total intensity is denoted as KI(n). We will calculate the intensity through the below formulas:
KI(m) = exp(-Weight*(K(m) - K(m-1)) * KI(m-1) + Weight
Where KI(n-1) is the previous total intensity.
BI(n) = exp(-Weight*(T(m) - T(m-1)) * AI(m-1) + Weight
where AI(n-1) is known as the previous accept intensity, provided that the value of exp(-Weight*(T(n) - T(n-1)) * AI(n-1) is less than MaxIntensity; else the value is
AI(n) = exp(-Weight*(T(n) - T(n-1)) * AI(n-1)
Speed is controlled by the value of the configuration parameter (Weight), and the intensities' calculations will react according to the changes in the input intensity. The inverted value of Weight will be denoted like as shown below,
T = 1/Weight
This value can be defined as the "time constant," which is the intensity calculation formulas. For example, if Weight = 0.1, then the input intensity change is denoted by the total and accepts the 10 seconds' intensities. The overload process defined one alarm, which sets the alarm_handler:set_alarm(Alarm). We will define the alarm as:
We will set this alarm when the current accept intensity exceeds MaxIntensity.
Now we will perform function overloading in Erlang, Erlang is a functional programming language:
Output of the above program will look like as shown below: