PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

Function Overloading

Function Overloading

Function Overloading is a feature.

The ability to create multiple functions of the same name with different implementations. Calls to an overloaded function will run a specific implementation of that function appropriate to the context of the call, allowing one function call to perform different tasks depending on context. This is a type of polymorphism.


Languages without Function Overloading include JavaScript, Ruby, Jule

Languages with Function Overloading include C++, Pascal

Example from C++:
// volume of a cube int volume(const int s) { return s*s*s; } // volume of a cylinder double volume(const double r, const int h) { return 3.1415926*r*r*static_cast<double>(h); }
Example from Pascal:
program Adhoc; function Add(x, y : Integer) : Integer; begin Add := x + y end; function Add(s, t : String) : String; begin Add := Concat(s, t) end; begin Writeln(Add(1, 2)); (* Prints "3" *) Writeln(Add('Hello, ', 'World!')); (* Prints "Hello, World!" *) end.
strings-feature.html 路 function-overloading-feature.html 路 hexadecimals-feature.html

View source

PLDB - Build the next great programming language 路 v2022 Day 33 Docs Build Acknowledgements Traffic Today Traffic Trends Mirrors GitHub feedback@pldb.com