Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Allows multiple functions with the SAME NAME but DIFFERENT PARAMETERS. The compiler determines which one to call based on the arguments provided.
int add(int a, int b); // Overload 1 double add(double a, double b); // Overload 2 int add(int a, int b, int c); // Overload 3
Functions must differ in the number of parameters or their data types.
Overloading based ONLY on return type is NOT allowed and will cause a compiler error.
This is a form of compile-time polymorphism. It makes the API cleaner as you don't need names like addInts, addDoubles, etc.