+ 2

I dont understand what is overloading?

13th Apr 2016, 5:57 PM
Shlomo Sfez (ShlomoSfezOfficial)
Shlomo Sfez (ShlomoSfezOfficial) - avatar
6 Answers
+ 9
Means same name but different argument list 🐈
8th May 2017, 12:31 AM
NimWing Yuan
NimWing Yuan - avatar
+ 7
If I understand this right, method overloading means that you can have more methods with the same name but with (must have) other parameters. If you got a method called "Calc" and it's parameters is (int x, int y) you can have another method called "Calc" but with the parameters (float x, float y). so whenever you call your method "Calc" and you want to Calculate an int you call the method with Calc (42, 43) and when if you want to calculate a float you call it with Calc (2.4, 5.3) Does this make sense?
15th Apr 2016, 6:51 PM
Mike Mortensen
Mike Mortensen - avatar
+ 3
If a function has the same signature as another, but differs in its parameters, it is said to be overloaded. Hence, you can create multiple methods with the same name, which differ in their implementation.
8th May 2017, 2:45 AM
AtK
+ 3
You can have 0 or more arguments, as long as they are different from the other function with the same name.
8th May 2017, 2:47 AM
AtK
+ 2
That make complete sense, so if you wanted you could overload a method that calculated the perimeter for different shapes Ex: public double Perimeter(double a, double b, double c)//triangle{...} public double Perimeter(double a)//square{...} public double Perimeter(double w, double h, )//rectangle{...} As long as the parameter signature is different you can overload a method until you run out shapes (joke). If you hover your cursor over Console.WriteLine you will see that it has over 18 overloads.
17th Apr 2016, 5:22 AM
ODLNT
ODLNT - avatar
+ 1
overloading the same operator or function for different purposes
29th Jul 2016, 2:32 AM
keerthana